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

What type of script and/or event should I use for this?

So, I made a script that once you click a book and have enough in-game currency, it will give you a unique sitting position. However, the script breaks when used in a local script (I already tried it inside of StarterPlayerScripts so it did run) and since it's not in a local script, that means that once a single person clicks on the book the entire server has the sitting position. I'm not looking for a script of any kind (unless it's about the script I'm showing), but it's about if I should use a different kind of script, if I should use remote events/functions, or if I need to use a different combination of both. Here's the script:

local book = game.Workspace.Claustrophobia.Union
local anim = game.Workspace.sitanim
local animscript = game.Workspace.Animation
book.ClickDetector.MouseClick:Connect(function(player)
	local rep = player:WaitForChild("leaderstats"):WaitForChild("Reputation")
	for i, v in pairs(game.Workspace:GetDescendants()) do
		if v.ClassName == "Seat" then
			if rep.Value >= 1000 then
			local scriptclone = animscript:Clone()
			scriptclone.Parent = v
			local animclone = anim:Clone()	
			animclone.Parent = v	
			end
		end
	end
end)

If you could help I would really like it!

1 answer

✓ Accepted answer

Use remote events. Execute this code on the server for when they click, and you should be fine.

Hope this helped!

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