I have a LocalScript in a playergui's ScreenGui, and what I want it to do whenever you click on the button is that your HUD turns invisible, you change character appearance, then load character, then get the weapons and boosts. This is what I have.
button.MouseButton1Down:connect(function()
if currentloadout.CharacterId.Value == 1 then
player.CharacterAppearanceId = 264064675
game:GetService("ReplicatedStorage").LoadCharacterEvent.OnServerEvent:connect(function(player)
player:LoadCharacter()
local humanoid = player.Character:FindFirstChild("Humanoid")
humanoid.MaxHealth = 150
humanoid.Health = 150
humanoid.WalkSpeed = 40
heroweapons:FindFirstChild("HeroSword"):clone().Parent = player.Backpack
hud:FindFirstChild("Deploy").Visible = false
hud:FindFirstChild("LoadoutHud").Visible = false
hud:FindFirstChild("Backgrounder").Visible = false
end)
end
end)
It doesn't load the character, so I added a RemoteEvent, the problem is, I'm still a bit new to RemoteEvents, and I'm still trying to find out how to use it properly.
Is this the correct way of using RemoteEvents? And are there bugs in the script that I need to fix?
Line four is cut off in this script, but it is actually
game:GetService("ReplicatedStorage").LoadCharacterEvent.OnSeverEvent:connect (function(player)

3 comments
I'm starting to understand the way that remoteevents are being used in this situation. Are there other ways of using them? Please link the wikia to me for RemoteEvents. And one more thing, Output says that it loadcharacter() can only be called in backend server. So does that mean I do LoadCharacter on the serverscript?
Yes, as a LocalScript cannot call LoadCharacter
thanks hiim! You really helped me out!