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

How do I make a gui appear for everyone when someone touches a part?

Asked by 3 years ago

local script

game.Workspace.Checkpoints.Stage1.Touched:Connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        game.ReplicatedStorage.ShowGUI:FireServer(game.Players:GetPlayerFromCharacter(hit.Parent))
    end
end)

local script

game.ReplicatedStorage.ShowGUI.OnClientEvent:Connect(function()
    script.Parent.Frame.Visible = true
end)

Please give an explanation, I am new to scripting so I won't understand otherwise. Thanks!

2 answers

Log in to vote
0
Answered by 3 years ago

Your first LocalScript has to be a regular script, inside ServerScriptService.

0
yea but then it says fireserver can only be called from the client DAB_VADER21 4 — 3y
0
Change the local script to be a server script, then instead of FireServer do FireClient. movementkeys 163 — 3y
0
this will show to all players in the game right? DAB_VADER21 4 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You can just use the local script to check if a part has been touched locally.

game.Workspace.Checkpoints.Stage1.Touched:Connect(function(hit)
    if game.Players[hit.Parent.Name] == game.Players.LocalPlayer then
        script.Parent.Frame.Visible = true
    end
end)

Also, local scripts only work when they're in the playergui, playerscripts, backpack and character. They will not execute anywhere else including serverscriptstorage or workspace.

0
* This would replace wherever the second local script you posted is. ChristianTRPOC 64 — 3y

Answer this question