✓ Accepted answer
Hi, I'm BlackOrange and I will be helping you out.
#Problem:#
- You did not specify what type of script this is
- You're looking in the wrong place.
- You need RemoteEvents
#Solution:#
A simple solution is to restart. First add a RemoteEvent to ReplicatedStorage. You can name it anything you want but I'm going to leave it as RemoteEvent. Next, go to your part and insert a Script. Inside the script you wanna start by a Touched event:
script.Parent.Touched:Connect(function(Hit)
end)
Now what you wanna do is add a LocalScript into the frame you want to appear. After that go to the LocalScript and type:
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
script.Parent.Visible = true
end)
Now head back to the script and what you wanna do is get the player. The method we are going to use is :GetPlayerFromCharacter(). First we want to check if a player touched the part though.
script.Parent.Touched:Connect(function(Hit)
if Hit:IsA('BasePart') and Hit.Parent:IsA('Model') and Hit.Parent:FindFirstChild('Humanoid') and game.Players:FindFirstChild(Hit.Parent.Name) then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
game.ReplicatedStorage.RemoteEvent:FireClient(Player)
end
end)
And you're done! Hope you learned something.
Best of luck developer!
EDIT: This was written from scratch, if an issue occurs please comment.
2 comments
There's supposed to be a ") on the end of GameOver. It is in the code.
I'm pretty sure you missed out the argument in FindFirstChild(argument). You should probably replace argument with the player's name: FindFirstChild("Escaper65")