I've already done the gui parts, i made a button, linked it up so when clicked enables a remote event, server script service script picks it up you know the good stuff, So all i need to know now is how i would give the player a hat.
Event:WaitForChild("Halo").OnServerEvent:Connect(function(Player) local workspaceplr = game.Workspace:FindFirstChild(Player.Name)
this part of the script gets me the name of the player so i can find it in workspace. So if i need to edit its humanoid or any character in there i can, I tried googling it but i just didn't get the right results. Any help would be nice
You don't need to search for the Character in workspace
; the initial act isn't as reliable as you'd think due to the potential complications of a name-based search. The Player object actually contains a reference to its respective Avatar through an attribute called 'Character', you can simply index that.
What you're looking for is the :AddAccessory() method of the Humanoid
Instance. You will have to manually Instantiate the Instance you wish to add onto the Humanoid, as this method takes the physical object rather than an AssetID
.
Assets within the Server are pre-loaded. On this end of the network, you don't need to worry about any load-latency with the Instances of your game, unless, under a special case, one wouldn't exist at the given time. You do not need to use :WaitForChild()
to reference Halo
, I suggest you simply write Event.Halo
to reduce the unnecessary time-complexity.