Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why my RemoteEvent does'nt work?

Asked by 2 years ago
Edited 2 years ago

I have a problem with the remote event. I wanted to re-make a owner only door, but got an problem. when the player passes the "test" that he's owner, then I fire his client by RemoteEvent. But nothing happends. There are 2 scripts

"Script"(location: workspace["Owner Only Door"].Door)

script.Parent.Touched:Connect(function(player) if player.UserId == game.CreatorId then game.ReplicatedStorage.TestPassed:FireClient(player) end end)

And "LocalScript"(location: game.StarterPlayer.StarterPlayerScripts)

game.ReplicatedStorage.TestPassed.OnClientEvent:Connect(function() workspace["Owner Only Door"].Door.Transparency = 0.5 workspace["Owner Only Door"].Door.CanCollide = false end)

2 answers

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Your mistake there is touched does not save player, it actually saves body part that touched it

so what you need to do is check whether or not if its player touching it, then get player and then compare whether it's owner or just some random player


--SERVERSCRIPT script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players[hit.Parent.Name] if player.UserId == game.CreatorId then game.ReplicatedStorage.TestPassed:FireClient(player) end end end) --LOCALSCRIPT game.ReplicatedStorage.TestPassed.OnClientEvent:Connect(function() workspace["Owner Only Door"].Door.Transparency = 0.5 workspace["Owner Only Door"].Door.CanCollide = false end)

I am sorry if there are any errors, I have not checked the code

0
Hello, thank you for help! I actually don't understand how I forgotten this... Shish20101 22 — 2y
0
No problem, its ok, it happens Sabailuridze 126 — 2y
Ad
Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Answer this question