I tried making a part that gives the players a jumpboost when they stepped on it. I stored it in the ReplicatedStorage so I can clone the jumpboost part and put it in the workspace. First the part will spawn in the workspace, and then it will give the player that touched the part a jumpboost, and then the part would proceed by destroying itself when it has been touched by the player and respawn again in the workspace. Unfortunately, it didn't work. The part didn't seem to spawn in. Here's the script:
local jumpBoost = game.ReplicatedStorage:FindFirstChild("JumpBoost") local clonedJumpBoost = jumpBoost:Clone() clonedJumpBoost.Parent = workspace local boostPart = game.ReplicatedStorage.JumpBoost local boostedJumpPower = 100 local function onPartTouch(otherPart) local partParent = otherPart.Parent local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") if ( humanoid ) then boostPart.CanCollide = false local currentJumpPower = humanoid.JumpPower if currentJumpPower < boostedJumpPower then humanoid.JumpPower = boostedJumpPower boostPart:Destroy() wait(10) humanoid.JumpPower = currentJumpPower end end end boostPart.Touched:Connect(onPartTouch) clonedJumpBoost.Parent = game.Workspace
The reason this isn't working is the local boostPart
in the code. Yes the value works but the code lines are using it for the one in ReplicatedStorage not in workspace.
Change them to clonedJumpBoost and see what happens then.
remade script with respawning the part, script doesn't work in ReplicatedStorage i recommend placing it in ServerScriptStorage, set the respawn value to false will stop the respawning
local jumpBoost = game.ReplicatedStorage:FindFirstChild("JumpBoost") local clonedJumpBoost = jumpBoost:Clone() clonedJumpBoost.Parent = workspace local boostedJumpPower = 100 local respawn = true --set to false to disable respawning local function respawn() if respawn then local jumpBoost2 = game.ReplicatedStorage:FindFirstChild('JumpBoost') local clonedJumpBoost2 = jumpBoost2:Clone() clonedJumpBoost2.Parent = workspace local boostedJumpPower = 100 local function onPartTouch2(otherPart) local partParent = otherPart.Parent local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") if humanoid then clonedJumpBoost2.CanCollide = false local currentJumpPower = humanoid.JumpPower if currentJumpPower < boostedJumpPower then humanoid.JumpPower = boostedJumpPower clonedJumpBoost2:Destroy() wait(10) humanoid.JumpPower = currentJumpPower wait(1) respawn() end end end clonedJumpBoost2.Touched:Connect(onPartTouch2) else return end end local function onPartTouch(otherPart) local partParent = otherPart.Parent local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") if humanoid then clonedJumpBoost.CanCollide = false local currentJumpPower = humanoid.JumpPower if currentJumpPower < boostedJumpPower then humanoid.JumpPower = boostedJumpPower clonedJumpBoost:Destroy() wait(10) humanoid.JumpPower = currentJumpPower wait(1) respawn() end end end clonedJumpBoost.Touched:Connect(onPartTouch)