I’m working on a script that would make sure only certain users can go through a part if a value in the character model is enabled. Problem is that instead of the part working for 1 user and not for the other, the script works on the client and everybody else. Pretty much I’m trying to make it to where all players that have a certain value enabled can go through the part while other players that have that certain value disabled can’t go through the part.
local Debounce = false
local inRegion = {}
function onTouched(value) do
if value.Touched:Connect(function(part)
local partParent = part.Parent
local player = game.Players:GetPlayerFromCharacter(partParent)
if player.IsBusyValue.Value == true and not Debounce then
Debounce = true
print("Working checkpoint!")
script.Parent.Parent.PartTest.CanCollide = true
wait()
Debounce = false
if player and player.IsBusyValue.Value == false and part:IsDescendantOf(game.Players.LocalPlayer.Character) then
script.Parent.Parent.PartTest.CanCollide = false
end
end
end) then
end
end
end
keep the end) but remove then
also your script is working for everybody else because its a serverscript, which will replicate for the server and the client.
so here’s how to do it :
fire a remote event to the client
ServerScript :
local Debounce = false
local inRegion = {}
function onTouched(value) do
if value.Touched:Connect(function(part)
local partParent = part.Parent
local player = game.Players:GetPlayerFromCharacter(partParent)
if player.IsBusyValue.Value == true and not Debounce then
Debounce = true
print("Working checkpoint!")
game.ReplicatedStorage.Collide:FireClient(player,true)
wait()
Debounce = false
if player and player.IsBusyValue.Value == false and part:IsDescendantOf(game.Players.LocalPlayer.Character) then
game.ReplicatedStorage.Collide:FireClient(player,false)
end
end
end) then
end
end
end
LocalScript :
local YourPartSpot = -- YourPartSpot
game.ReplicatedStorage.Collide.OnClientEvent:Connect(function(bool)
YourPartSpot.CanCollide = bool
end)
It would be better to use Collision Filtering to make it so specified people don’t collide with the part at all. Your system means that one person may trail behind the other player quick enough where multiple players can get through at the same time as long as one player is allowed.