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 2 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 2 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 — 2y
0
Change the local script to be a server script, then instead of FireServer do FireClient. movementkeys 163 — 2y
0
this will show to all players in the game right? DAB_VADER21 4 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 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 — 2y

Answer this question