I've recently been dabbling in coding and tried to make your generic power-up script. However, whenever I run the game I get the feedback "Duration is not a valid member of part." If I delete the duration line, It just says "Jump is not a valid member of part." How would I attempt to fix this? (This problem has also cropped up in many of my other scripts as well.)
local PowerUp = script.Parent local duration = PowerUp.Duration.Value local speedamount = PowerUp.Speed.Value local jumpamount = PowerUp.Jump.Value local CanTouch = true local function GivePower(part) local hum = part.Parent:FindFirstChild("Humanoid") if hum and CanTouch then CanTouch = false local originalspeed = hum.WalkSpeed local originaljump = hum.JumpPower hum.WalkSpeed = speedamount hum.JumpPower = jumpamount PowerUp.Transparency = 1.0 wait(duration) PowerUp.Transparency = 0.0 hum.WalkSpeed = originalspeed hum.JumpPower = originaljump CanTouch = true end end
Any help would be greatly appreciated!
You didn't add the Duration value, here is the fix
local PowerUp = script.Parent local durationMain = instance.new("IntValue") local speedamount = PowerUp.Speed.Value local jumpamountMain = instance.new("IntValue") local CanTouch = true local duration = durationMain.Value local jumpamount = jumpamountMain.Value duration = --add the duration value here jumpamount = --add the jump amount value here local function GivePower(part) local hum = part.Parent:FindFirstChild("Humanoid") if hum and CanTouch then CanTouch = false local originalspeed = hum.WalkSpeed local originaljump = hum.JumpPower hum.WalkSpeed = speedamount hum.JumpPower = jumpamount PowerUp.Transparency = 1.0 wait(duration) PowerUp.Transparency = 0.0 hum.WalkSpeed = originalspeed hum.JumpPower = originaljump CanTouch = true end end