Hey! I'm trying to make a wand and I want a part that goes from a part from my wand to the location on my mouse pointer (And also have a short distance, as I don't want people to spam from across the map)
How can I achieve something like this? I also play an animation so here's the script to not get confused: (Also, I do already have the part, tho I'm confused if I should put it in the ReplicatedStorage and copy it from there)
local player = game.Players.LocalPlayer
local Tool = script.Parent
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local debounce = false -- New variable
local waitTime = 3 -- New variable
local frame = player.PlayerGui:WaitForChild("MageGui").MainFrame.Ebackground.Edelay
local function debounceToFalse(didComplete)
if didComplete then
debounce = false
else
print("Something went wrong")
end
end
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local AnimE = Instance.new("Animation")
AnimE.Name = "AnimE"
AnimE.Parent = script.Parent
AnimE.AnimationId = "http://www.roblox.com/asset/?id=6757120886"
local animEtrack = humanoid:LoadAnimation(AnimE)
UserInputService.InputBegan:Connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.E and not gameProcessed and not debounce then
debounce = true
animEtrack:Play()
frame.Size = UDim2.new(0, 1, 0, 39)
frame:TweenSize(
UDim2.new(0, 225, 0, 39),
Enum.EasingDirection.In,
Enum.EasingStyle.Linear,
waitTime,
true,
debounceToFalse
)
end
end)
