print("Teleport Spell Loaded")
local COOLDOWN = 0
local MP = 0
bin = script.Parent
function TryToCast(player)
-- returns true if player may cast this spell
-- make sure this player has the wizard board stats
local stats = player:findFirstChild("leaderstats")
if stats == nil then return false end
local mana = stats:findFirstChild("Mana")
local level = stats:findFirstChild("Level")
if mana == nil or level == nil then
return false
end
if (mana.Value >= MP) then
mana.Value = mana.Value - MP
return true
end
return false
end
function animation()
local f = Instance.new("ForceField")
part = Instance.new("Part")
f.Parent = part
char = game.Players.LocalPlayer.Character
part.Parent = char
part.CanCollide = false
part.Anchored = true
part.Size = Vector3.new(1,1,1)
part.BrickColor = BrickColor.Yellow()
part.Transparency = .8
part.Reflectance = 0
part.formFactor = 0
part.Name = "Box"
part.TopSurface = 0
part.BottomSurface = 0
part.CFrame = char.Torso.CFrame
grow()
end
function grow(pos)
while part.Size.y < 10 do
wait(.02)
part.Size = Vector3.new(part.Size.x+1, part.Size.y+1, part.Size.z+1)
part.CFrame = char.Torso.CFrame
end
shrink(pos)
end
function grow2()
while part.Size.y < 10 do
wait(.02)
part.Size = Vector3.new(part.Size.x+1, part.Size.y+1, part.Size.z+1)
part.CFrame = char.Torso.CFrame
end
shrink2()
end
function shrink(pos)
local p = char:GetChildren()
while part.Size.y > 1 do
wait(.02)
part.Size = Vector3.new(part.Size.x-1, part.Size.y-1, part.Size.z-1)
part.CFrame = char.Torso.CFrame
end
for i=1,#p do
if p[i].className == "Part" then
p[i].Transparency = 0
end
if p[i].Name == "Box" then
p[i].Transparency = .8
end
end
local b = part:clone()
b.Parent = char
b.Shape = "Ball"
b.ForceField:remove()
b.Transparency = .2
b.Size = Vector3.new(1,1,1)
b.CFrame = char.Torso.CFrame
while b.Size.y < 10 do
wait(.04)
b.Size = Vector3.new(b.Size.x+1, b.Size.y+1, b.Size.z+1)
b.CFrame = char.Torso.CFrame
end
b:remove()
for i=1,#p do
if p[i].className == "Part" then
p[i].Anchored = false
end
if p[i].Name == "Box" then
p[i].Anchored = true
end
end
char.Torso.CFrame = CFrame.new(Vector3.new(cf.p.x, cf.p.y + 7, cf.p.z))
for i=1,#p do
if p[i].className == "Part" then
p[i].Anchored = true
end
end
grow2()
end
function shrink2()
local p = char:GetChildren()
while part.Size.y > 1 do
wait(.02)
part.Size = Vector3.new(part.Size.x-1, part.Size.y-1, part.Size.z-1)
part.CFrame = char.Torso.CFrame
end
for i=1,#p do
if p[i].className == "Part" then
p[i].Transparency = 0
end
if p[i].Name == "Box" then
p[i].Transparency = .2
end
end
local b = part:clone()
b.Parent = char
b.Shape = "Ball"
b.ForceField:remove()
b.Transparency = .2
b.Size = Vector3.new(1,1,1)
b.CFrame = char.Torso.CFrame
part:remove()
while b.Size.y < 10 do
wait(.04)
b.Size = Vector3.new(b.Size.x+1, b.Size.y+1, b.Size.z+1)
b.CFrame = char.Torso.CFrame
end
for i=1,#p do
if p[i].className == "Part" then
p[i].Anchored = false
end
if p[i].Name == "Box" then
p[i].Anchored = true
end
end
b:remove()
wait(COOLDOWN)
enabled = true
end
function teleportPlayer(pos)
local player = game.Players.LocalPlayer
if player == nil or player.Character == nil then
return
end
local char = player.Character
sound = Instance.new("Sound")
sound.SoundId = ""
sound.Parent = char
sound.PlayOnRemove = true
sound:remove()
local p = game.Players.LocalPlayer.Character:GetChildren()
for i=1,#p do
if p[i].className == "Part" then
p[i].Anchored = true
end
end
animation(pos)
end
enabled = true
function onButton1Down(mouse)
if not enabled then
return
end
Player = script.Parent.Parent.Parent
local player = game.Players.LocalPlayer
if player == nil then return end
if TryToCast(player) == false then
return
end
enabled = false
mouse.Icon = "rbxasset://textures\\ArrowFarCursor.png"
-- find the best cf
cf = mouse.Hit
local v = cf.lookVector
teleportPlayer(cf.p)
wait(COOLDOWN)
mouse.Icon = "rbxasset://textures\\ArrowCursor.png"
enabled = true
end
function onSelected(mouse)
mouse.Icon = "rbxasset://textures\\ArrowCursor.png"
mouse.Button1Down:connect(function() onButton1Down(mouse)
end)
end
bin.Selected:connect(onSelected)
COMMUNITY QUESTION
Something wrong at this teleport script? idk what happened
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
What even is the error
tbh idk, but it was suppose to teleport the player