You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want IntValue to be normal
-
What is the issue? When while wait(5) do the generate coin thing, It’s normal, But IntValue is broken when it’s generated
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?, Yes I look for the hub
- I try printing in almost the end of Generate Script and it’s normal
- More Info
- No script disturbing IntValue
- IntValue that inserted is a Number
- I use WaitForCHild on IntValue
- If you want more info, Feel free to ask me when I am online!
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
A code of Generate Coins script
local coin = script.Parent:WaitForChild("coin")
while wait(5) do
local chance = math.random(1,10000) / 100
local clonedCoin = coin:Clone()
local toReward = clonedCoin:WaitForChild("rewardCoin").Value
local lobbyFloorSize = workspace:WaitForChild("lobbyFloor").Size
clonedCoin.Position = Vector3.new(math.random(-(lobbyFloorSize.X / 2), lobbyFloorSize.X / 2), lobbyFloorSize.Y + 5, math.random(-(lobbyFloorSize.Z / 2), lobbyFloorSize.Z / 2))
if chance < 50 then
if chance >= 25 then
clonedCoin.Name = "Uncommon Coin"
clonedCoin.Color = Color3.fromRGB(37, 255, 44)
toReward = 10
elseif chance >= 10 then
clonedCoin.Name = "Rare Coin"
clonedCoin.Color = Color3.fromRGB(65, 151, 255)
toReward = 25
elseif chance >= 5 then
clonedCoin.Name = "Epic Coin"
clonedCoin.Color = Color3.fromRGB(146, 37, 255)
toReward = 50
elseif chance >= 1 then
clonedCoin.Name = "Mythical Coin"
clonedCoin.Color = Color3.fromRGB(255, 0, 0)
toReward = 75
elseif chance >= 0.5 then
clonedCoin.Name = "Superior Coin"
clonedCoin.Color = Color3.fromRGB(233, 244, 22)
toReward = 100
elseif chance >= 0.1 then
clonedCoin.Name = "Luckiest Coin"
clonedCoin.Color = Color3.fromRGB(37, 255, 44)
toReward = 1000
elseif chance >= 0.01 then
clonedCoin.Name = "DIVINE COIN"
clonedCoin.Color = Color3.fromRGB(253, 255, 130)
toReward = 6969
else
--Something
end
elseif chance > 50 then
clonedCoin.Name = "Coin"
toReward = 1
elseif chance == 50 then
clonedCoin.Name = "GODLYCOIN"
clonedCoin.Color = Color3.fromRGB(255,255,255)
toReward = 10000
local light = Instance.new("PointLight")
light.Parent = clonedCoin
light.Range = 60
light.Brightness = 40
light.Color = Color3.fromRGB(255,255,255)
local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.Parent = clonedCoin
proximityPrompt.HoldDuration = 30
proximityPrompt.ObjectText = "GOLDY COIN"
else
--Something
end
clonedCoin.Parent = workspace:WaitForChild("coinFolder")
--This is where I print toReward and it not result 0 and nil
end
A code for Giving coins to player
local coin = script.Parent
coin.Touched:Connect(function(part)
if part.Parent:IsA("Model") and part.Parent:WaitForChild("Humanoid") then
local userToGive = part.Parent.Name
game.Players:WaitForChild(userToGive):WaitForChild("leaderstats"):WaitForChild("Coins").Value += coin:WaitForChild("rewardCoin").Value
coin:Destroy()
end
end)
Feel Free to ask me!
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.