The code is for some rocket boots but they are not currently working, this is my local script in the starterGui:
player = game.Players.LocalPlayer
spacedown = false
mouse = player:GetMouse()
startedDown = 0
character = player.character
mouse.KeyDown:connect(function(key)
if key:lower() == " " then
spacedown = true
startedDown = tick()
end
end)
mouse.KeyUp:connect(function(key)
if key:up() == " " then
spacedown = false
end
end)
function Elevate()
if character["Left Leg"]:findFirstChild("Rocketboot") ~= nil and character["Right Leg"]:findFirstChild("Rocketboot") ~= nil then
if spacedown then
print("Was held for ", tick() - startedDown,"seconds")
-- Time between now and when `startedDown` was set
if tick() - startedDown > 2 then -- If held for longer than 2 seconds
local float = Instance.new("BodyVelocity", character.Torso).force
float.Parent.name = "float"
float = Vector3(0, 196.2*character.Torso:GetMass(), 0) -- Apply force to make the character levitate
local body = Instance.new("BodyVelocity",character.Torso) --Create BodyVelocity and Parents it to Player's Torso.
body.name = "Body"
body.maxForce = Vector3.new(1e7,1e7,1e7)--The the Maximum amount of force the BodyVelocity can use.
body.velocity = character.Torso.CFrame.lookVector*40*2--Change the Body's Velocity to the way the Character's Head if facing.
character["Left Leg"]:findFirstChild("Rocketboot").Thrust1.Transparency = 0.5
character["Right Leg"]:findFirstChild("Rocketboot").Thrust2.Transparency = 0.5
end
elseif not spacedown then
character.Torso.float:remove()
character.Torso.body:remove()
character["Left Leg"]:findFirstChild("Rocketboot").Thrust1.Transparency = 1
character["Right Leg"]:findFirstChild("Rocketboot").Thrust2.Transparency = 1
end
end
end
spacedown.Changed:connect(Elevate)
Please can you tell me of any point in which my code is inefficient or could use improvement, currently the error is on line 5:
11:07:11.442 - character is not a valid member of Player 11:07:11.443 - Script 'Players.Player.PlayerGui.LocalScript', Line 5 11:07:11.444 - Stack End
