So, I tried to make this game, and I ran into this problem. if and elseif ran at the same time and it’s not supposed to. Here’s video footage:
So here’s my local script:
local Score = game.Players.LocalPlayer:FindFirstChild("Stats"):WaitForChild("ArrowScore")
local TimeWait = 0.5
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Point = ReplicatedStorage:WaitForChild("ArrowPoint")
local Damage = ReplicatedStorage:WaitForChild("ArrowDamage")
local Arrow = game.Players.LocalPlayer:WaitForChild("Stats"):WaitForChild("Arrow")
script.Parent.Arrows.ChildAdded:Connect(function(child)
TimeWait = (0.5 + (Score.Value + 1)/(Score.Value + 1) - ((Score.Value + 1)/100))
wait(TimeWait * 2)
if child.Name == "UpArrow" then
if Arrow.Value == 1 then
Point:FireServer(TimeWait)
elseif Arrow.Value ~= 1 then
Damage:FireServer(TimeWait)
end
end
if child.Name == "RightArrow" then
if Arrow.Value == 2 then
Point:FireServer(TimeWait)
elseif Arrow.Value ~= 2 then
Damage:FireServer(TimeWait)
end
end
if child.Name == "DownArrow" then
if Arrow.Value == 3 then
Point:FireServer(TimeWait)
elseif Arrow.Value ~= 3 then
Damage:FireServer(TimeWait)
end
end
if child.Name == "LeftArrow" then
if Arrow.Value == 4 then
Point:FireServer(TimeWait)
elseif Arrow.Value ~= 4 then
Damage:FireServer(TimeWait)
end
end
wait(0.01)
for i = 1,10 do
child.ImageTransparency = child.ImageTransparency + 0.1
wait(0.01)
end
child:Destroy()
end)
and here’s my server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- [UserInputService (SpeedingArrows)] --
local ArrowBind = ReplicatedStorage:WaitForChild("ArrowBind")
ArrowBind.OnServerEvent:Connect(function(player, value, play)
play.Value = value
end)
-- [ArrowPoints (SpeedingArrows)] --
local ArrowPoint = ReplicatedStorage:WaitForChild("ArrowPoint")
ArrowPoint.OnServerEvent:Connect(function(player,ScoreAdding)
local Stats = player:WaitForChild("Stats")
if Stats ~= nil then
local Score = Stats:WaitForChild("ArrowScore")
if Score ~= nil then
Score.Value = Score.Value + math.ceil(((50 + (1 + ScoreAdding) * (1 + ScoreAdding)) / ScoreAdding)/54)
print("Point")
end
end
end)
-- [ArrowHealth (SpeedingArrows)] --
local ArrowHealth = ReplicatedStorage:WaitForChild("ArrowDamage")
ArrowPoint.OnServerEvent:Connect(function(player,ScoreAdding)
local Stats = player:WaitForChild("Stats")
if Stats ~= nil then
local Health = Stats:WaitForChild("ArrowHealth")
if Health ~= nil then
Health.Value = Health.Value - math.ceil(((10 + ScoreAdding) * ScoreAdding)/ ScoreAdding)
print("Damage")
end
end
end)
These are the locations of the scripts and the remote events.
if you can, please help me fix this problem. All help is greatly appreciated.
If you’d like, can you tell me how to improve my scripts? I’m a very nooby scripter.