doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
So I'm converting a game to filteringEnabled, and I'm using a RemoteFunction to cross the 'boundary', but it's not working. Can anyone tell me why?
--Local Script
function SavePlayerCar()
local CarToClone = game.Workspace:WaitForChild(plr.Name .. "s_CustomCar")
local CarClone = CarToClone:Clone()
local CarName = CarToClone.Car.CarName.Value
local CarPack = game.Lighting:WaitForChild(plr.Name.."s_CarPack")
--Save car to player's custom car pack
CarPack:WaitForChild(CarName):remove()
CarClone.Parent = CarPack
CarClone.Name = CarName
game.Workspace.Events.CarSaver:InvokeServer(CarClone)
end
script.Parent.Save.MouseButton1Click:Connect(SavePlayerCar)
--Server Script
function game.Workspace.Events.CarSaver.OnServerInvoke(Player, CarClone)
print(CarClone.Name)
end
And it's saying that CarClone is a Nil Value in the server script. |
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
bump1 |
|
LaeMVPJoin Date: 2013-06-24 Post Count: 4416 |
Destroy not remove |
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
That's not what I asked. |
|
caca50Join Date: 2011-07-10 Post Count: 2037 |
Put the remote function in replicated storage
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
Replacing 'remove()' with 'Destroy()' won't do anything for what I'm asking. |
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
and caca50, that didn't work. |
|
caca50Join Date: 2011-07-10 Post Count: 2037 |
I can see you're using a lot of things that are not recommended anymore. As already mentioned, use :Destroy(), not :remove() Use ReplicatedStorage for housing instances that should be used by both the server and the client. Use ServerStorage for storage for the server, not Lighting. Lighting should only deal with skies, visual effects, etc. Use ServerScriptService to house server scripts, workspace will also work for this. A LocalScript will only run Lua code if it is a descendant of one of the following objects: A Player's Backpack, such ## # ##### of a Tool A Player's Character model A Player's PlayerGui A Player's PlayerScripts The ReplicatedFirst service Make sure your local script abides by those rules^ After you fix those issues, post back here if the problem persists. Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
caca50Join Date: 2011-07-10 Post Count: 2037 |
I can see you're using a lot of things that are not recommended anymore.
As already mentioned, use :Destroy(), not :remove()
Use ReplicatedStorage for housing instances that should be used by both the server and the client.
Use ServerStorage for storage for the server, not Lighting. Lighting should only deal with skies, visual effects, etc.
Use ServerScriptService to house server scripts, workspace will also work for this.
A LocalScript will only run Lua code if it is a descendant of one of the following objects:
A Player's Backpack, such as a descendant of a Tool
A Player's Character model
A Player's PlayerGui
A Player's PlayerScripts
The ReplicatedFirst service
Make sure your local script abides by those rules^
After you fix those issues, post back here if the problem persists.
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
So I adjusted for things that needed to be adjusted that you listed, yet it still doesn't work.
--Local Script, in the player's GUI
function SavePlayerCar()
local CarToClone = game.Workspace:WaitForChild(plr.Name .. "s_CustomCar")
local CarClone = CarToClone:Clone()
local CarName = CarToClone.Car.CarName.Value
local CarPack = game.ReplicatedStorage:WaitForChild(plr.Name.."s_CarPack")
--Save car to player's custom car pack
CarPack:WaitForChild(CarName):Destroy()
CarClone.Parent = CarPack
CarClone.Name = CarName
game.ReplicatedStorage.Events.CarSaver:InvokeServer(CarClone)
end
script.Parent.Save.MouseButton1Click:Connect(SavePlayerCar)
--Server Script, in ServerScriptService
function game.ReplicatedStorage.Events.CarSaver.OnServerInvoke(Player, CarClone)
print(CarClone.Name)
end
And it's still saying that CarClone is a nil value. |
|
|
print CarClone.Name on the client and tell me if the name prints |
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
Yep, it printed fine on the client. |
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
bump |
|
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
Anyone else have an idea? |
|
caca50Join Date: 2011-07-10 Post Count: 2037 |
"CarClone.Parent = CarPack"
Is CarPack nil?
Any other errors?
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
Nope, the only error is that CarClone is nil. |
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
And it's an error on the Server script. |
|
caca50Join Date: 2011-07-10 Post Count: 2037 |
"local CarToClone = game.Workspace:WaitForChild(plr.Name .. "s_CustomCar")"
How exactly is CarToClone being instantiated? If it's being created on the client, then that's your problem
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
All of this is taking place on the Client's workspace, and I'm trying to copy a car that only exists for the client and replicate it so the server into a custom bin for the player to use later. |
|
caca50Join Date: 2011-07-10 Post Count: 2037 |
Create the car in the server
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
But I only want 1 player to see it; the player who spawned it. In this case, they are customizing their car, not spawning it to be driven.
I have the system for spawning a car for driving done.
|
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
bump |
|
doot_d0otJoin Date: 2012-10-26 Post Count: 1709 |
bump |
|