|
| 09 Aug 2017 03:16 PM |
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. |
|
|
| Report Abuse |
|
|
| |
|
LaeMVP
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
| |
|
| |
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 09 Aug 2017 03:34 PM |
Put the remote function in replicated storage
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2017 03:34 PM |
| Replacing 'remove()' with 'Destroy()' won't do anything for what I'm asking. |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2017 03:38 PM |
| and caca50, that didn't work. |
|
|
| Report Abuse |
|
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 09 Aug 2017 03:44 PM |
| 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) |
|
|
| Report Abuse |
|
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 09 Aug 2017 03:45 PM |
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) |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2017 05:49 PM |
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. |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2017 05:50 PM |
| print CarClone.Name on the client and tell me if the name prints |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2017 05:53 PM |
| Yep, it printed fine on the client. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 09 Aug 2017 06:32 PM |
"CarClone.Parent = CarPack"
Is CarPack nil?
Any other errors?
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2017 06:43 PM |
| Nope, the only error is that CarClone is nil. |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2017 06:44 PM |
| And it's an error on the Server script. |
|
|
| Report Abuse |
|
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 09 Aug 2017 06:46 PM |
"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) |
|
|
| Report Abuse |
|
|
| |
|
|
| 09 Aug 2017 07:40 PM |
| 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. |
|
|
| Report Abuse |
|
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 09 Aug 2017 07:56 PM |
Create the car in the server
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2017 08:14 PM |
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.
|
|
|
| Report Abuse |
|
|
| |
|
| |
|