Basically, I am making an adventure game and I need coins.
I coded the rotation of the coins using the runservice.Heartbeat event
Here is the code:
--scripted by supermanover00
local runservice = game:GetService("RunService")
local coin = script.Parent
local taken = coin:WaitForChild("Taken")
local remoteevent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local debounce = true
local respawntime = 180
local function onTouched(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if debounce and player and humanoid and humanoid.Health > 0 then
debounce = false
coin.Transparency = 1
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1
wait(respawntime)
debounce = true
coin.Transparency = 0
end
end
local function rotateLoop()
coin.Orientation = coin.Orientation + Vector3.new(0,4,0)
end
coin.Touched:connect(onTouched)
runservice.Heartbeat:connect(rotateLoop)
I am basically just wondering if this will give the game substantial issues if I have this coded inside every single coin (and there will be loads).
Thanks!