08:21:43.584 Workspace.ActivationPad.Pad.Pad:2: attempt to index nil with 'PlayerGui' - Server - Pad:2
08:21:43.585 Stack Begin - Studio
08:21:43.585 Script 'Workspace.ActivationPad.Pad.Pad', Line 2 - Studio - Pad:2
08:21:43.585 Stack End - Studio
script.Parent.Touched:Connect(function(BasePart)
if BasePart.Parent:FindFirstChild("Humanoid") then
game.Players:GetPlayerFromCharacter(BasePart.Parent).PlayerGui:WaitForChild("ToggleButtons").StanderedShopOpen.OpenShop.Visible = true
end
end)
script.Parent.TouchEnded:Connect(function(BasePart)
if BasePart.Parent:FindFirstChild("Humanoid") then
game.Players:GetPlayerFromCharacter(BasePart.Parent).PlayerGui:WaitForChild("ToggleButtons").StanderedShopOpen.OpenShop.Visible = false
end
end)
-- Try it.
Well, the script you sent won’t work in a server script. Doing game.Players.LocalPlayer on the server will try finding a player called “LocalPlayer”, which isn’t what you want to do.
Try the code that DeadBlox sent, instead of looking for the local player (which doesn’t work on the server), the code checks what player touched the part using GetPlayerFromCharacter and changes their gui.
script.Parent.Touched:Connect(function(part)
if part.Parent:FindFirstChild('Humanoid') then
local player = game.Players:GetPlayerFromCharacter(part.Parent)
player.PlayerGui:WaitForChild("ToggleButtons").StanderedShopOpen.OpenShop.Visible = true
end
end)
script.Parent.TouchEnded:Connect(function(part)
if part.Parent:FindFirstChild('Humanoid') then
local player = game.Players:GetPlayerFromCharacter(part.Parent)
player.PlayerGui:WaitForChild("ToggleButtons").StanderedShopOpen.OpenShop.Visible = false
end
end)