So I’ve got a brick that I’ve created using a localscript so that each player sees there own part. At the moment all I want to do is to change the colour of that part after 5 seconds of it being created but the Localscript I have inside of the part isn’t doing anything once it gets moved to Workspace. Any ideas?
Local scripts don’t run in workspace.
so no local scripts directly tied to a part in workspace will run, to run a script from a public space you need to use a regular script
local scripts dont run inside workspace…
I recommend putting a cloned script inside the player when the block is created… this allows for it to change color on client while also having it run.
I also tried using a regular script but I’m assuming because the part is local it won’t run.
Sorry could you expand on this? I’m not entirely sure what that is suggesting.
Can you explain what you mean by local part, I assume you mean a part created by the client?
Yeah sorry I thought that was what they were referred to as.
so then what you’re gonna want to do is run whatever script you want from a local script in a local space ie StarterCharacterScripts, Starter Gui, etc
Put a server script inside the part so that when the part is moved to the workspace this server script is executed and will manipulate the part as desired.
When you create the part do something like this:
local tempPart = Instance.new("Part", workspace) -- or maybe the clone function
spawn(function()
task.wait()
-- color change code
end)
LocalScripts don’t run in workspace.
Definition: A LocalScript is a Lua source container that runs Lua code on a client connected to a Roblox server. They are used to access client-only objects, such as the player’s Camera
. For code run through LocalScripts, the LocalPlayer property of the Players
service will return the player whose client is running the script.
--local script inside StarterPlayerScripts
local part = Instance.new("Part", workspace)--creates a part on the client
part.BrickColor = BrickColor.new("Black")--or whatever color you want