So I was making a Simulator (you may already know on my first question) I wanted to add a touch event to a MeshPart to open up the Frame. It works but only once for some reason.
The shop script:
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then plr.PlayerGui.Shop.Frame.Visible = true end end end)
The rebirth script:
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then plr.PlayerGui.Rebirth.Frame.Visible = true end end end)
NOTE: BOTH OF THESE ARE SERVER SCRIPTS
Any help would be appreciated!
Try putting them both in LocalScripts
. GUIs should usually be accessed by clients.
Shop Script
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then game.Players.LocalPlayer.PlayerGui.Shop.Frame.Visible = true end end end)
Do the same with your rebirth script by using game.Players.LocalPlayer instead of GetPlayerFromCharacter.
Hope this helps!
You cannot modify GUI's on the server, you need to convert the scripts script into localscripts and just use LocalPlayer to check if they touched the part.