Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my Speed boost script say "Duration is not a valid member of part."?

Asked by 3 years ago

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!

0
Double check if the Duration is in the parent of the script. Also, did u add these Int/Number values by default or using a script? BestCreativeBoy 1395 — 3y
0
I added them by default. They are in the part that the script is inside. Should I put the values inside the script? Boomboyag 14 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

0
Well, I already have the values (as number values) inside the part. Is the script above supposed to replace those values? Boomboyag 14 — 3y
Ad

Answer this question