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

What's wrong with this script?

Asked by 10 years ago

I edited this script I found to make a fire before you teleport

Players=game:service'Players';
LP=Players.LocalPlayer;
Mouse=LP:GetMouse()
Units=16 -- Number of units to teleport
Shift=false -- True when left shift is pressed
DefaultSpeed=0

fart = Instance.new("Part")
fart.Name = "farter"
fart.Transparency = 1
fart.Size = Vector3.new(1,1,1)
fart.Anchored = true
fart.CanCollide = false
Fire = Instance.new("Fire", fart)
Fire.Color = Color3.new(0,0,255)
Fire.SecondaryColor = Color3.new(0,0,150)


SetBody=function(Player,Toggle)
    if Player.Character and Player.Character:FindFirstChild("Humanoid") then
        if Toggle==0 then
            DefaultSpeed=Player.Character.Humanoid.WalkSpeed
            Player.Character.Humanoid.WalkSpeed=16
        elseif Toggle==1 then
            Player.Character.Humanoid.WalkSpeed=DefaultSpeed
        end
    end
end

Teleport=function(Player,Direction)
    if Shift and Player.Character and Player.Character:FindFirstChild("Torso") and Player.Character:FindFirstChild("Humanoid") and Player.Character:FindFirstChild("Humanoid").Health~=0 then
        if Direction==113 then
            fata=fart:Clone()
            fata.Position = Player.Character.Torso
            Player.Character.Torso.CFrame=Player.Character.Torso.CFrame*CFrame.new(-Units,0,0)
        elseif Direction==101 then
            fata=fart:Clone()
            fata.Position = Player.Character.Torso
        Player.Character.Torso.CFrame=Player.Character.Torso.CFrame*CFrame.new(Units,0,0)
        end
    end
end

Mouse.KeyDown:connect(function(Key)
    KeyByte=string.byte(Key)
    if KeyByte==48 then
        Shift=true
        SetBody(LP,0)
    else
        Teleport(LP,KeyByte)
        wait(0.2)
    end
end)
Mouse.KeyUp:connect(function(Key)
    KeyByte=string.byte(Key)
    if KeyByte==48 then
        SetBody(LP,1)
        Shift=false
    end
end)

I can't seem to find what's wrong.

I am a beginner scripter, so any help is greatly appreciated. Also, please explain what I did wrong and how to do it right. Thanks :D

Answer this question