You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I got a script that fires a event that gives you a point, so when you fire it once, it gives you one point. - What is the issue? Include screenshots / videos if possible!
The issue is that when I fire it in my script, it gives me like 7 points, which means it fires it 7 times for no reason. I am utilizing it in another script, for another ui, and it works perfectly there.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
The script that fires it: The event is at the bottom.
local order = {}
local click = true
local orderer = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if click and script.Parent.Parent.ListAmount.Value >= 1 and script.Parent.Parent.CustomerServe.Text ~= '' and game.Players:FindFirstChild(script.Parent.Parent.CustomerServe.Text) then
script.Parent.Parent.Parent.Parent.Tablets.OpenMenu.Value = 'false'
click = false
for i, x in pairs(script.Parent.Parent.Order:GetChildren()) do
if x:IsA("Frame") then
table.insert(order,x.Name)
end
end
print(unpack(order));
wait(1)
game.ReplicatedStorage.Tablets:FireServer(order,script.Parent.Parent.TableNum.Value,script.Parent.Parent.CustomerServe.Text)
for i, x in pairs(script.Parent.Parent.Order:GetChildren()) do
if x:IsA("Frame") then
x:Destroy()
end
end
for k in pairs (order) do
order[k] = nil
end
script.Parent.Parent.ListAmount.Value = 0
script.Parent.Parent.TableNum.Value = ''
-----------------------------------------------------------------------------------
script.Parent.Parent.CustomerServe.Text = ''
for i, x in pairs(script.Parent.Parent:GetChildren()) do
if x:IsA("ScrollingFrame") and x.Name ~= 'Display' or x:IsA("ScrollingFrame") and x.Name ~= 'Order' then
x.Visible = false
script.Parent.Parent:TweenPosition(UDim2.new(0.205, 0, 1.25, 0),"In", "Linear",1.0,true)
wait(1)
game.ReplicatedStorage.GivePoint:FireServer()
wait(0.1)
script.Parent.Parent.Visible = false
------------------------------------------------------------------------------------------
click = true
wait(script.Parent.Parent.OrderCoolDown.Value)
script.Parent.Parent.Parent.Parent.Tablets.OpenMenu.Value = 'true'
end
end
end
end)
The event script, that tells what the event is for: Remember this connects other events too.
game.Players.PlayerAdded:Connect(function(Player)
local Stat = Instance.new("NumberValue",Player)
Stat.Name = 'Stats'
local Stat2 = Instance.new("NumberValue",Stat)
Stat2.Name = 'OrderClaim'
local DataStoreService = game:GetService("DataStoreService")
local PointsStore = DataStoreService:GetDataStore("PointsStore")
local SavedPoints = PointsStore:GetAsync(Player.UserId)
local Leaderstats = Instance.new("Folder", Player)
Leaderstats.Name = "leaderstats"
local PointsValue = Instance.new("IntValue", Leaderstats)
PointsValue.Name = "Points"
if SavedPoints ~= nil then
PointsValue.Value = SavedPoints
PointsValue.Changed:Connect(function(NewPoints)
PointsStore:SetAsync(Player.UserId, NewPoints)
end)
end
end)
game.ReplicatedStorage.Claim.OnServerEvent:Connect(function(player,id)
player.Stats.OrderClaim.Value = 1
game.ReplicatedStorage.Claim:FireAllClients(id)
end)
game.ReplicatedStorage.Claim2.OnServerEvent:Connect(function(player)
player.Stats.OrderClaim.Value = 0
end)
game.ReplicatedStorage.GivePoint.OnServerEvent:Connect(function(player)
player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
end)