Hi, so I have this code to make a gui appear when a player touches a part.
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
game.ReplicatedStorage.RemoteEvent:FireClient(plr)
end
end)
However I want to make a different gui appear when a player touches a different part so how would I change this code?
This could work as well but rather than making a lot of RemoteEvents I suggest adding a second argument what to open
--Shop
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
game.ReplicatedStorage.RemoteEvent:FireClient(plr,"Shop")
end
end)
--Setings
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
game.ReplicatedStorage.RemoteEvent:FireClient(plr,"Settings")
end
end)
Instead of using remotes at all, you can just have the client detect touches against a part, verify it’s the current client then open a Gui based on what part was touched. There’s no need to be crossing the client-server boundary here at all.