Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

An if statement doesn't work the way I planned?

Asked by
royee354 129
5 years ago

I am having a problem with an if statement, I am trying to do so the code won't execute if there is an object in the workspace called "Laser" and if he has a child that is named the Player's name.

if game.Workspace:FindFirstChild("Laser"):FindFirstChild(Player.Name)then
    print("LaserInActionAlready")
    elseif not game.Workspace:FindFirstChild("Laser"):FindFirstChild(Player.Name)then
wand.Activated:Connect(function(Mouse)
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)

Why the first 3 lines won't make sure that the remote event doesn't get fired if there is an object called "Laser" and inside it an object with the character's name that is my question, I would be happy if someone could help.

0
If you haven't tried already you could put a stringvalue in there, and put the name in there, then you'd do if game.Workspace:FindFirstChild("Laser").stringvalue.Value==Player.Name then, this technically isn't an answer so I'm not posting it as that. Inconcinnus 90 — 5y
0
Ill try royee354 129 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

This is because the script you have isn’t wrapped in a function, loop, or event.

Since you didn’t wrap it into one of these, the if statements automatically ran, and checked only once. Another error is you put your Tool.Activated event inside an of statement, which is not okay. On top of that, you tried to pass the mouse as a parameter. The Tool.Activated event has no parameters.

0
I have tried to put it inside of a OnServerEvent scope but it didn't work. royee354 129 — 5y
0
I don't see how me putting it in a function can help with my problem. royee354 129 — 5y
Ad

Answer this question