So im trying to make a script that grants players a random superpower upon pressing a button
i tried making the superpower as an item that gives you the powers when you equip it (i mean it appears in the backpack but you cant physically hold it)
the problem is that i made a code that should speed you up once you “equip” the speed superpower but for some reason it does not work
local character = player.Character -- Gets the Players Character
local humanoid = character:FindFirstChild("Humanoid") -- Gets the Humanoid
player.Backpack.speed.Equipped:Connect(function() -- speed is the name of the superpower
if humanoid then -- Checks if its the Humanoid
humanoid.WalkSpeed = 32 -- Doubles the Speed of the Player
end
end)
player.Backpack.speed.Unequipped:Connect(function()
if humanoid then -- Checks if its the Humanoid
humanoid.WalkSpeed = 16 -- The Normal Speed of The Player
end
end)
It does appear in the backpack but once you use it it doesn’t change anything
Can the problem be cause of the scripts location?
the current location of the script is in Replicated Storage in the speed tool and its a local script
if not then i really have no idea why isnt it working
basically i just want to make a speed coil that doesn’t show up in your hand
hopefully yall can point me in the right direction
local player = game:GetService("Players").LocalPlayer
local character = player.Character -- Gets the Players Character
local humanoid = character:FindFirstChild("Humanoid") -- Gets the Humanoid
local tool = script.Parent
tool.Equipped:Connect(function() -- speed is the name of the superpower
if humanoid then -- Checks if its the Humanoid
humanoid.WalkSpeed = 32 -- Doubles the Speed of the Player
end
end)
tool.Unequipped:Connect(function()
if humanoid then -- Checks if its the Humanoid
humanoid.WalkSpeed = 16 -- The Normal Speed of The Player
end
end)
Hmm, still doesn’t work
ok lets start from the beginning. Where do i store items so they dont automatically appear in the players backpack, but appear there only after certain criteria is met?
Well you need to clone it into your backpack which means after you press the button it will clone it to your character. The ReplicatedStorage is just there for you to keep a main copy so that you can clone it multiple times.