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

Remote events work in studio but not in player?

game.ReplicatedStorage.build.OnServerEvent:connect(function(player,color,
building,translation)
	--repeat wait() until building
	local buil = building:Clone()--clone cause reason
	for i,v in pairs(buil:GetChildren()) do
		if v.Name == "Recolor" then--recolor
			v.BrickColor = BrickColor.new(color.Color)--color is the players teamcolor
		end
	end
	spawn(function()_G.build(buil,25,30)end)--a function that works
	buil:TranslateBy(translation)--translate, cause yea
	wait()--because reasons
	buil.Parent = game.Workspace
end)

It works fine in studio, but in player, it says in the console something about building being nil. When I uncomment line 3, it never goes. I assume it stops there forever. building is a model btw, and I really don't know why this isn't working. I fire it from this:

game.ReplicatedStorage.build:FireServer(color,sendB,toTranslate)--sendB is the model

6 comments

0

Edit this to show where you fire this event, please.

0

done

0

My bad, not too experienced with remote events and functions

0

I mean, if you haven't, you might as well try it.

0

Tried it, got this Clone is not a valid member. Probably because you can't clone a color.

0

You deleted the answer! LOL

1 answer

I think it might be because you try to send an object over RemoteEvent. If the object isn't available both on server and client(for example, client creates an instance with filtering enabled or client creates object which is not parented if filtering is off). Remote event only sends a reference to the object, not the whole thing.

5 comments

0

That does seem to be the problem, but how do i fix the problem?

0

Don't know, you'd need to provide more details like which scripts is which(local or regular), what exactly you are passing to the event.

0

LocalScript is sending the part, what happens is this: http://pastebin.com/2cd4h6hd

0

Yeah, instead you should pass name of the model you want to build, and make the server clone it from replicated storage directly.

0

Ok, i'll try that

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