So I am making a new game with a Coconuts currency and a level system but I want Coconuts to give both Coconuts and Experience (I already have the level system) but how do I make one Coconut give both? Here is my script:
currency = "Coconut" amnt = 1 debounce = false function onTouch(hit) if hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == false then if game.Players:findFirstChild(hit.Parent.Name) ~= nil then ThisPlayer = game.Players:findFirstChild(hit.Parent.Name) ThisPlayer.leaderstats:findFirstChild(currency).Value = ThisPlayer.leaderstats:findFirstChild(currency).Value + amnt script.Sound:Play() script.Parent.Transparency = 1 script.Parent.CanCollide = false debounce = true wait(15) script.Parent.Transparency = 0 script.Parent.CanCollide = false debounce = false end end end script.Parent.Touched:connect(onTouch)
Here you go!
currency = "Coconut" currency2 = "Experience" amnt2 = 1--Change this to the amout you want amnt = 1 debounce = false function onTouch(hit) if hit.Parent:findFirstChild("Humanoid") and debounce == false then if game.Players:findFirstChild(hit.Parent.Name) then ThisPlayer = game.Players:findFirstChild(hit.Parent.Name) local Cononuts = ThisPlayer.leaderstats:FindFirstChild("Coconuts") local XP = ThisPlayer.leaderstats:FindFirstChild("Experience") XP.Value = XP.Value + amnt2 Coconuts.Value = Coconuts.Value + amnt script.Sound:Play() script.Parent.Transparency = 1 script.Parent.CanCollide = false debounce = true wait(15) script.Parent.Transparency = 0 script.Parent.CanCollide = false debounce = false end end end script.Parent.Touched:connect(onTouch)
I hope this helps you! Tell me if it dosen't work and your error if it not work. Bye!