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?

5 comments
Thanks so much !
wait but one more thing how would I be able to have the weapon be cloned before giving it to the player? so like when I click R a cloned weapon appears in the players hand. That way people could summon it again after they die
do "local toolclone = workspace.Tool:Clone()" followed by "character.Humanoid:EquipTool(a)"
Sorry I meant "character.Humanoid:EquipTool(toolclone)" make sure you remove the quotations lol
Thx so much guys I appreciate it