Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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!

2 comments

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?

0

I added them by default. They are in the part that the script is inside. Should I put the values inside the script?

1 answer

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

1 comment

0

Well, I already have the values (as number values) inside the part. Is the script above supposed to replace those values?

This discussion is preserved as it was. New answers, comments, and votes are closed.