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

How do i make this teleport only if u have the tool??

Asked by 6 years ago
Edited 6 years ago

So i made a script that teleports me to different areas. I never had any expierence with making it a tool so i was wondering how i could only telport if i have the tool and after I press x.

Here is the local Script:

local Tool = script.Parent
local repstore = game:WaitForChild("ReplicatedStorage")
local Remote = repstore:WaitForChild("LightStart")
local player = game.Players.LocalPlayer
mouse = player:GetMouse()


local en = true
Tool.Activated:connect(function()
 if not en then return end
 en = false
 wait(2)
 en = true
end)


Cool = true
mouse.KeyDown:Connect(function(key)
    key = key:lower()
    if key == "x" then
        if Cool ~= true then return end
        Cool = false
        Remote:FireServer(mouse.Hit)            
        wait(1)
        Cool = true


end


end)

Here is the teleport script:

local Tool = script.Parent
local repstore = game:WaitForChild("ReplicatedStorage")
local Remote = repstore:WaitForChild("LightStart")


Remote.OnServerEvent:Connect(function(Player, mouse)

local Folder = workspace:FindFirstChild("DebrisFolder") or Instance.new("Folder",   workspace)
Folder.Name = "DebrisFolder"

local bolt = Instance.new("Part")
bolt.Name = "Electrode"
bolt.BrickColor = BrickColor.new("New Yeller")
bolt.FormFactor = "Custom"
bolt.Material = "Neon"
bolt.Transparency = 0
bolt.Size = Vector3.new(0.1,0.1,0.1)
bolt.CanCollide = false
bolt.Anchored = true

function ShootElectrode(from,too)
    lastpos = from
    local Step = 3
    local Off = 10
    local Range = 400

    local Distance = (from-too).magnitude

    for i = 0,Distance, Step do
        local from = lastpos
        local offset = Vector3.new(
            math.random(-Off,Off),
            math.random(-Off,Off),
         math.random(-Off,Off)
                                )/10

    local too = from + - (from-too).unit*Step + offset



    local p = bolt:Clone()
    p.Parent = Folder
    p.Size = Vector3.new(p.Size.x,p.Size.y,(from-too).magnitude)
    p.CFrame = CFrame.new(from:Lerp(too,0.5),too)


    game.Debris:AddItem(p,0.2)
    lastpos = too



    end

end 







local from = Player.Character.Head.Position
local too = mouse.Position + Vector3.new(0,0,0)
local maxdis = 400

if (from-too).magnitude <= maxdis then
ShootElectrode(from,too)



local Electric = Instance.new("Sound")
Electric.SoundId = "rbxassetid://157325701"
Electric.MaxDistance = 500
Electric.Parent = Player.Character.Head
Electric.PlaybackSpeed = 1
Electric:Play()
local Electric2 = Instance.new("Sound")
Electric2.SoundId = "rbxassetid://153613030"
Electric2.MaxDistance = 500
Electric2.Parent = Player.Character.Head
Electric2.PlaybackSpeed = 1
Electric2:Play()
game.Debris:AddItem(Electric2,3)
game.Debris:AddItem(Electric,3)






Player.Character:MoveTo(mouse.Position)



local Inside = Instance.new("Part")
Inside.Name = "Inside"
Inside.Parent = Folder
Inside.Anchored = true
Inside.CanCollide = false
Inside.Material = "Neon"
Inside.Shape = "Ball"
Inside.BrickColor = BrickColor.new("New Yeller")
Inside.Transparency = .3
Inside.Size = Vector3.new(5,5,5)
Inside.CFrame = Player.Character.LowerTorso.CFrame




local Inside2 = Instance.new("Part")
Inside2.Name = "Inside"
Inside2.Parent = Folder
Inside2.Anchored = true
Inside2.CanCollide = false
Inside2.Material = "Neon"
Inside2.Shape = "Ball"
Inside2.BrickColor = BrickColor.new("Institutional white")
Inside2.Transparency = .3
Inside2.Size = Vector3.new(5,5,5)
Inside2.CFrame = Player.Character.LowerTorso.CFrame
game.Debris:AddItem(Inside,1)
game.Debris:AddItem(Inside2,1)



local function Size()
    local TweenService = game:GetService("TweenService")
    local TweenInform = TweenInfo.new(
        .5,
        Enum.EasingStyle.Linear,
        Enum.EasingDirection.Out,
        0,
        false,
        0
    )



local properties = {
    Size = Vector3.new(17,17,17),
    Transparency = 1    
}
local properties2 = {
    Size = Vector3.new(17,17,17),
    Transparency = 1    
}



    local Tween = TweenService:Create(Inside,TweenInform,properties)
    local Tween2 = TweenService:Create(Inside2,TweenInform,properties2)
    Tween:Play()
    Tween2:Play()
end
Size()





    end
end)
0
are you getting anything in the output? the8bitdude11 358 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

NeverMInd

Ad

Answer this question