–this is my script to get through a door when you get a certain amount of cash but, when someone buys it, it buys for the whole server. I’ve tried putting it in a local script but it just doesn’t work. Can someone please tell me how I can fire for only one client
local rc = 2500
local debounce = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”)then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.leaderstats.Cash.Value >= rc then
if debounce then
debounce = false
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 2500
script.Parent.Transparency = 0.5
script.Parent.CanCollide = false
if rc.Value <= rc then
script.Parent.Transparency = 0.5
script.Parent.CanCollide = true
end
end
end
end
end)
111122233333; I have no clue what you’re trying to do.
If you could; at least next time; format your code to make it easier to read, use ``` these to format your code. Ex: ``` code ```
However, your entire system is flawed. A script runs on the server. That means anything it does replicates to all the clients. You have a few options here:
Use a localscript:
parent the localscript to a starterPlayer container (starterplayerscripts or startercharacterscripts) and change the script.Parent things to the path to the part that needs to be touched, and make sure you check that the player is the localplayer. However, this means it won’t change the cash value, so you need a client + server system.
Use remote events. Place one in ReplicatedStorage and name it whatever you want, and instead of
@Styre_x
Okay so it worked! Tysm. But only thing is I have those all around the map lol would i have to repeat the step or would there be a more simple way like putting the local script into the door or would that break it?