Why does my speedup power not work?

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 :wink:

3 Likes

why not make a script inside the tool object then access the tool object within the script e.g.

local tool=script.Parent --gets tool object
2 Likes

This right here is the problem.
Scripts cant run in ReplicatedStorage

Try parenting it onto the tool or in StarterPlayerScripts

4 Likes

the speed power is paranted to the tool already or did you mean some other tool?

2 Likes

The same tool. Also local scripts don’t work in Workspace only normal scripts. Try changing it to normal scripts and setting the RunContext to client
image

2 Likes

but the script is not int the worspace. its in replicated storage in an additional file

try this script

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.


Here I added a localscript so that when you press the button it will give you the power.

Here is the File if you want to see it working in action
Help11.rbxl (59.9 KB)

(I wasn’t sure why creating a tool for me didn’t work out so well so I just copied the sword from roblox lol)

To clarify, localscripts do not run anywhere other than StarterPlayerScripts, StarterCharacterScripts, StarterGui, or the player’s Backpack.

local character = player.Character or player.CharacterAdded:Wait()

LocalScript will run in tools equipped by the player, as they will be under the player’s character

Correct, but only because it was originally in the backpack, as per the runtime.