So I have a local script inside of a ScreenGui. It works, but it opens the gui for everyone in the server. Is there a way to fix it? I’m not much of a sciprter.
This should be a localscript, because the Touched event fires on the server (i think)
so if script.Parent.ShopFrame is in StarterGui it should work with a server script like this
workspace.EarthWorld.TrailShop.ShopPart.Touched:Connect(function(hit)
if game.Players:FindFirstChild(hit.Parent.Name) then
local PlayerGui = game.Players[hit.Parent.Name].PlayerGui
local Frame = PlayerGui. YourWayToTheFrame --Change to the target (.screengui.frame maybe?)
Frame.Visible = true
end
end)
The reason why your code isn’t working is because you aren’t checking if the LocalPlayer is touching the part. This can be fixed by checking if the hit part is a player and then check if that player is the LocalPlayer.
Fixed code:
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
game.Workspace.EarthWorld.TrailShop.ShopPart.Touched:Connect(function(hitPart)
if Players:GetPlayerFromCharacter(hitPart.Parent) == LocalPlayer then
script.Parent.ShopFrame.Visible = true
end
end)
Its kinda complicated if you dont know whats going on in your game’s scripts.
Usually remotes are in ReplicatedStorage, but the important thing would be check the remotes that could be FireAllClients() referencing that GUI… Read the game scripts and understand them.
Thats true, but make no sense on the topic. A touched even in a server script, yeah it will fire in server side, a touched event in client side, will fire in client side, thats all.
If other clients are getting their client gui affected, its because a remore calling client scripts, to perform a change on the GUI