I'm making a teleport tool for this magic game, It's supposed to show a ray of light when teleporting and then It disappears after 1 second. It teleports but it only creates a brick with no mesh and isn't anchored like it's supposed to be...
--- Alonzo12345 print("Teleport Spell Loaded")
local COOLDOWN = 0 local MP = 0 local mouse = game.Players.LocalPlayer:GetMouse()
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 teleportPlayer(pos)
local player = game.Players.LocalPlayer
if player == nil or player.Character == nil then return end
local char = player.Character.Torso
sound = Instance.new("Sound")
sound.SoundId = ""
sound.Parent = char
sound.PlayOnRemove = true
sound:remove()
char.CFrame = CFrame.new(Vector3.new(pos.x, pos.y + 7, pos.z))
--ERROR HERE-------ERROR HERE--
--Creates the LightingBrick local L = Instance.new("Part") L.Parent = game.Workspace L.Size = Vector3.new(4, 4, 4) L.Position = char.Position
--Adds Light local light = Instance.new("PointLight", L) light.Brightness = 15 light.range = 15
--Adds Mesh local mesh = Instance.new("BlockMesh", L) mesh.Scale = Vector3.new(1, 99, 1) L.Anchored = true L.CanCollide = false L.Transparency = 0.5
--Removes
wait(1)
L:Remove()
sound = Instance.new("Sound")
sound.SoundId = ""
sound.Parent = char
sound.PlayOnRemove = true
sound:remove()
end
enabled = true function onButton1Down(mouse) if not enabled then return end
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
local cf = mouse.Hit
local v = cf.lookVector
teleportPlayer(cf.p)
wait(COOLDOWN)
mouse.Icon = "rbxasset://textures\\ArrowCursor.png"
enabled = true
end
function onSelected() mouse.Icon = "rbxasset://textures\ArrowCursor.png" b1d = mouse.Button1Down:connect(function() onButton1Down(mouse) end) end function onDeselected() b1d:disconnect() end bin.Deselected:connect(onDeselected) bin.Selected:connect(onSelected)
