I've been trying to figure out what do to when the mouse is out of the max range for the fire shower thingy. The question I wanted to ask is how do I code, for example, when the mouse goes out of the max range it'll just set the position of the fireshower to the direction of the mouse but on the border of the max range. I hope I explained it clearly because I don't know if I did. Here's the whole script below:
wait(4)
script.Parent.Ferid.OnServerEvent:Connect(function(Player, Mouse)
local maxrange = 50
script.Parent.Parent.Parent.Data.Tries.Value = script.Parent.Parent.Parent.Data.Tries.Value + 30
local AlreadyTouched = false
local Character = Player.Character or Player.CharacterAdded:wait()
local torso = Character.UpperTorso
local Shower = game.ReplicatedStorage.FireShower:Clone()
Shower.Parent = game.Workspace
for i,v in pairs(Shower:GetDescendants()) do
if v:IsA("Part") then
local distance = (Mouse.Position-torso.Position).Magnitude
if distance < maxrange then
v.CFrame = v.CFrame + Mouse*Vector3.new(Mouse.Position,Mouse.Position,Mouse.Position)
else
--code when it's out of maxrange should be put here
end --This part's the line of code that controls the shower's position.
end
v.Touched:Connect(function(hit)
if hit.Parent.Name ~= nil then
local yo = hit.Parent:findFirstChild("Humanoid")
if yo == Character then
yo.Health = yo.Health - 0
elseif hit.Parent.Name ~= nil and hit.Parent ~= Shower:GetDescendants() then
local tween = game:GetService("TweenService")
local boom = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local boomprop = {Anchored = true;CanCollide = false;Transparency = 1;Size = Vector3.new(48,48,48) }
local ew = tween:Create(v,boom,boomprop)
ew:Play()
wait(1.5)
Shower:Destroy()
end
end
end)
end
end)

1 comment
magnitude