so I want it so that when R is clicked a weapon automaticlly equips on you (in this case a sword) but for some reason it doesnt work.
local BladeDash = game.StarterGui.Red.RedPower1.REDpower1 local player = game.Players.LocalPlayer local character = player.Character function onKeyPress(actionName, userInputState, inputObject) if userInputState == Enum.UserInputState.Begin then if BladeDash.Value == true then print ("hi") Workspace.player.Humanoid:EquipTool(Workspace.Tool) end end end game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.R)
so my issue is that roblox says "player is not part of workspace" how do I fix this?
The player
you referenced doesn't refer to your character, it instead refers to the player instance in game.Players
. Simply just use player.Character
instead of workspace.player.
EDIT: just realized you had a variable for character already, just use character instead :P