Hello i am making a console for my game i have made a working version using a local script but i need it to use a server script instead so i can add developer commands. Like giving items to people or spawning in npc's or giving players currency. But in my script i cant get a reference to the player that clicked the textbutton to run the command that they type. When i click the run command buttton it does nothing and no errors saying player is nil or somthing.
heres the entire script. It's inside of a textbutton which is in a ScreenGui in StarterGui
script.parent.MouseButton1Click:Connect(function()
game.Players.PlayerAdded:Connect(function(player)
local backpack = player.Backpack
repeat wait() until player.Character -- wait for character to load
local torso = player.Character.Torso
local input = script.Parent.Parent.input
local output = script.Parent.Parent.OutputFrame.output
local tool = game.ReplicatedStorage.Weapons.KeyCard1
local RemoteEvent = script.Parent.RemoteEvent
output.Text = input.Text -- set output.Text to whatever user types in input
--|| USER COMMANDS ||--
if input.Text == "!commands" then -- list available commands
output.Text = [[
--PLAYER COMMANDS--
scl_Brightness= <--number value 1-5
scl_Inventory.Clear
--DEVELOPER COMMANDS--
scl_giveKeyCard
]]
end
if input.Text == "scl_Inventory.Clear" then -- drop items in backpack
backpack:ClearAllChildren()
end
--| DEVELOPER COMMANDS |--
if input.Text == "scl_giveKeyCard" and player.Name == "Cletdawg" or player.Name == "SpaceCitizenDev" then
RemoteEvent:FireServer(tool)
wait(0.2)
end
end)
end)