Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Player.Parent cannot be changed, but I am not even trying to change that?!

The Gyazo Link In this picture, Archery is the model's name I am trying to change parent, but it says "Player's parent cannot be changed". Why? Here is my part of code I'm doing that. It's two different scripts.

AB = game.ReplicatedStorage.allBuilds
send1 = Building:Clone()
send2 = AB:FindFirstChild("Constructing"):Clone()
print(send1)
print(send2)
game.ReplicatedStorage.allRemotes.Construct:InvokeServer(send1,send2,Tile)
function game.ReplicatedStorage.allRemotes.Construct.OnServerInvoke(CB,Co,Tile)
CB.Parent = game.Workspace.BuildModel
Co.Parent = game.Workspace.BuildModel

1 answer

✓ Accepted answer

##Problem

This first argument passed to the OnServerInvoke from an InvokeServer function is the player object. This is done by default as to know which client attempted to contact the server.


##Solution

Add a dummy variable in place of the player argument in the function.


##Final Script

function game.ReplicatedStorage.allRemotes.Construct.OnServerInvoke(player, CB,Co,Tile)
CB.Parent = game.Workspace.BuildModel
Co.Parent = game.Workspace.BuildModel
--Player is a dummy argument for the player object in this case.

######Hopefully this answer helped. If this answered your question, hit the accept answer button. If you have any questions leave them in the comments below and I will get back to you.

1 comment

0

Thanks, I had to read it three times but it helped alot

This discussion is preserved as it was. New answers, comments, and votes are closed.