You shouldn’t do this .touched doesn’t always return a player
And firing the client every time it is touched will just crash the game
See: FireClient and Touched. Touched passes a part. Aim to use GetPlayerFromCharacter from the parent model of the part. You can use either Parent or FindFirstAncestorOfClass(“Model”) for this.
@uugnut6 Would be more helpful if you replied with more information, like what it does fire with. Also just to be clear: firing the client in Touched events will not crash the game. Please get the right information if you’re looking to offer help.
(Also please try to post minimally! This isn’t a chat server, it’s a forum, multiple posts is sort of spammy - you can edit new content in.).
So everything seemed correct and it didn’t even give me an error but it still isn’t letting the “player” to go through the door.
Server Script inside part
local part = script.Parent
local debounce = false
part.Touched:Connect(function(touched)
local Player = game.Players:GetPlayerFromCharacter(touched.Parent)
if not Player then return end
if debounce == false then
game.ReplicatedStorage.DoorAccess:FireClient(Player)
wait(10)
debounce = true
end
end)
Local Script inside StarterPlayerScripts
local Player = game.Players.LocalPlayer
local debounce = false
local part = game.Workspace["Leaderstat Door for tutorial"]
local character = game.Players.LocalPlayer.Character
game.ReplicatedStorage.DoorAccess.OnClientEvent:Connect(function(Player)
if character and part:IsDescendantOf(character) then
if Player.leaderstats.Money.Value >= 1000 then
if debounce == false then
debounce = true
print(Player.DisplayName.." has went on the other side of the door!")
part.Transparency = 0.5
part.CanCollide = false
wait(10)
debounce = false
end
else
print(Player.DisplayName.." doesn't have enough money!")
end
end
end)
Consider doing some debugging. You could throw some quick prints throughout the code to check what is and isn’t running. If your script isn’t producing errors but it doesn’t do what you expect it to do then it could be a problem of not having the right conditions met. For example, you’re checking if the leaderstat door is a descendant of the character yet it’s in the workspace so that obviously wouldn’t pass.