I'm trying to make it to where when a player clicks on another player a gui opens on their screen. I have this as a local script:
local Player = game.Players.LocalPlayer -- Getting the player
local Mouse = Player:GetMouse() -- Getting the players mouse
Mouse.Button1Down:Connect(function() -- Detecting when player presses the left mouse button
if Mouse.Target.Parent:FindFirstChild("Humanoid") and
game.Players.LocalPlayer.TeamColor.Name == ("Dirt brown") then -- Checking if the Mouse is over a player
print(Mouse.Target.Parent.Name)
local mousetarget = Mouse.Target.Parent
game.ReplicatedStorage.SellPistol:FireServer(mousetarget)
end
end)
Someone told me to use get player on the script this connects to under ServerScriptService:
local SellPistol = game.ReplicatedStorage.SellPistol
local function onSellPistol(player, mousetarget)
local target = game:GetService("Players")[mousetarget.Name]
target.PlayerGui.StartScreen.Frame.Visible = true
print("Debug")
end
SellPistol.OnServerEvent:Connect(onSellPistol)
now the debug prints but the gui doesn't open why?

2 comments
Sorry if the indentation or I guess the whole code looks weird. I had to do this on mobile, so I have no idea what the code block looks like to you. But I hope this helps!
no problem it still helps