Ok so, I have 2 scripts one is a local that is inside of a tool and inside of it is a global script, in the local script there are 2 values, "Done" and "Busy", "Done" doesn't really has a use. Anyways, the job for the local script is to fire the remote event that is inside of the global script only when I say the word "Duro" doesn't matter if it is in caps or not, and when I click while having the tool equipped, and to pass 2 arguments: the Mouse's hit and Mouse's hit position. Once the global script runs with the OnServerEvent event of the remote event it supposed to do ray casting with a beam shooting from the tip of the tool, it works just fine but, there is a small problem, sometimes randomly the script won't shoot the beam, it happens randomly ususally when I spam "Duro" and click (the local script is named duro btw), there are the scripts:
LocalScript:
local wand = script.Parent
local inc = script.Name
local owner, Connect
local Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
function Setup()
for i,p in pairs(game.Players:children()) do
if p.Character == wand.Parent then
print("Found owner of wand!")
if Connect ~= nil then Connect:Disconnect() end
Connect = p.Chatted:Connect(PlayerTalked)
owner = p
end
end
end
function PlayerTalked(words)
print("Someone talked!")
if string.find(words:lower(), inc:lower() ~= nil) and wand.Parent == owner.Character then
print("Casting the spell ''" ..inc.. "''")
script.Busy.Value = false
script:WaitForChild("Aqua eructo"):WaitForChild("RemoteFunction").OnClientInvoke = function()
return
end
script["Aqua eructo"].Disabled = false
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA('LocalScript') then
print("it's a local")
local s = v:WaitForChild("Busy")
if s.ClassName == "BoolValue" and s.Name == "Busy" and s.Parent ~= script then
print("Horray")
local Busy = s
Busy.Value = true
end
end
end
if owner.Character.Torso:FindFirstChild("Torso") then return end
if owner.Character.Humanoid.JumpPower == 0 then return end
print("Really?")
enabled = true
wand.Activated:Connect(function()
local Mousehit = game.Players.LocalPlayer:GetMouse().Hit
local Mousehitp = game.Players.LocalPlayer:GetMouse().Hit.p
if script.Busy.Value == true then
script["Aqua eructo"].Disabled = true
end
if script.Busy.Value == false then
if enabled == true then
enabled = false
if not script["Aqua eructo"].Disabled == true then
script.Done.Value = false
script["Aqua eructo"].RemoteEvent:FireServer(Mousehitp,Mousehit)
end
end
end
end)
end
end
wand.Equipped:Connect(Setup)
Script:
script.RemoteEvent.OnServerEvent:connect(function(Player,Mousehitp,Mousehit)
repeat wait() until Player.Character
Character = Player.Character
tool = script.Parent.Parent
local laser = Instance.new("Part")
laser.Name = "Laser"
laser.TopSurface, laser.BottomSurface = 0, 0
laser.Size = Vector3.new(0.2, 0.2, 5)
laser.Transparency = 1
laser.BrickColor = BrickColor.Gray()
laser.Material = "Plastic"
laser.Anchored = true
laser.CanCollide = false
laser.Locked = true
laser.CFrame = tool.Tip.CFrame
laser.Parent = game.Workspace
local Trail = script.Trail:Clone()
Trail.Parent = laser
local attachment0 = Instance.new("Attachment" ,laser)
attachment0.Name = "TrailAttachment0"
local attachment1 = Instance.new("Attachment" ,laser)
attachment1.CFrame = attachment1.CFrame * CFrame.new(0,-0.25,0)
attachment1.Name = "TrailAttachment1"
Trail.Attachment0 = attachment0
Trail.Attachment1 = attachment1
game.Debris:AddItem(laser,5)
local maxDistance = 400
local curDistance = 0
local stepDistance = 6.5
local stepWait = 0.025
local StartPoint = tool.Tip.Position + Vector3.new(0,0.2,-0.45)
local EndPoint = Mousehit.lookVector
local function Step(overrideDistance)
local dir = (Mousehitp -StartPoint).Unit
-- Cast ray:
local ray = Ray.new(StartPoint, dir*1 * (overrideDistance or stepDistance))
local hit, pos, norm = game.Workspace:FindPartOnRayWithIgnoreList(ray, {tool,Character})
-- Update laser position:
laser.CFrame = CFrame.new(StartPoint:lerp(pos, 0.5), pos)
local oldPos = StartPoint
StartPoint = pos
laser.Transparency = 1
if (hit) then
laser:Destroy()
end
curDistance = (curDistance + (pos - oldPos).magnitude)
-- Apply fade effect to laser as it approaches max distance from < 75 studs:
if (curDistance > (maxDistance - 75)) then
local d = (curDistance - (maxDistance - 75)) / 75
laser.Transparency = d
end
-- Recurse if max distance not reached:
if (curDistance < maxDistance) then
wait(stepWait)
Step()
end
end
Step()
-- Done! Destroy laser:
script.Parent.Done.Value = true
end)

16 comments
Well duh we need the scripts, they must already be provided.
There.
Think that you can help me? I think that the problem is minor, but I am just too dumb to realise that.
What it is I mean.
Why did you wrap your if statements in brackets, like in line 67 of your server scripts? And on lines 10, 12, and 21 on your localscript? Why are you using deprecated code?
I was used to do that in the past, let me fix it.
And on line 43, the Activated event has no parameters, and you’re trying to use the Mouse’s Hit and Hit.p properties, when the mouse is client side only. And on line 7 of your server script, FormFactor is deprecatedz
Passing the Mouse's hit from the client is just fine though, what is wrong is passing the Mouse itself. Am I right?
Thanks for letting me know about those depreacated stuff it can save my scripts in the future.
What do I need to add to activated? The mouse parameter?
I got confused, the Hit and stuff is okay, it’s the Mouse object that isn’t. In the Activated, there is no parameter. So remove it.
And i’m not trying to judge you but please indent your code, it makes reading it much easier. I see you manually remove the indentation, please don’t. I also see you squeeze your if statements all in one line, don’t, as it makes it hard to read. Just trying to help you and others so it’s more legible.
Oh ok.
I am totally on your side here, I am not complaining I really need you to help me.
Removed the mouse parameter.
Found the reason why?