I'm trying to make this this where if a player(s) clicked on a model in-game, it'd give them exp and then they'll have to wait(300) seconds for the player(s) to click it again. So how would I start it?
function onExpChanged(player, Exp, Level) if Exp.Value>=Level.Value * 10 then Exp.Value = Exp.Value - Level.Value * 30 Level.Value = Level.Value + 1 end end function onLevelUp(player, Exp, Level) if player.Character~=nil then for i = 1,5 do local fireworks = Instance.new("Part") fireworks.Shape = 0 fireworks.formFactor = "Symmetric" fireworks.Size = Vector3.new(1,1,1) fireworks.BrickColor = BrickColor.Random() fireworks.CFrame = player.Character.Head.CFrame + Vector3.new(0,2,0) fireworks.Parent = game.Workspace game:GetService("Debris"):AddItem(fireworks, 2) fireworks.Velocity = Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30)) end end local m = Instance.new("Hint") m.Parent = game.Workspace m.Text = player.Name .. " has leveled up!" wait(3) m.Parent = nil end function onPlayerRespawned(player) wait(5) player.Character.Humanoid.Health = player.leaderstats.Level * 999 player.Character.Humanoid.MaxHealth = player.leaderstats.Level * 1000 --[[ local stuff = player.Backpack:GetChildren() wait(5) for i = 1,#stuff do local name = stuff[i].Name if game.Starterpack:findFirstChild(name)==nil then stuff[i]:Clone().Parent = player.Backpack end end --]] end function onPlayerEntered(newPlayer) local stats = Instance.new("IntValue") stats.Name = "leaderstats" local Exp = Instance.new("IntValue") Exp.Name = "Exp" Exp.Value = 0 local Level = Instance.new("IntValue") Level.Name = "Level" Level.Value = 1 local Coins= Instance.new("IntValue") Coins.Name = "Coins" Coins.Value = 0 Exp.Parent = stats Level.Parent = stats Coins.Parent = stats stats.Parent = newPlayer Exp.Changed:connect(function() onExpChanged(newPlayer, Exp, Level) end) Level.Changed:connect(function() onLevelUp(newPlayer, Exp, Level) end) newPlayer.Changed:connect(function (property) if (property == "Character") then onPlayerRespawned(newPlayer) end end) end game.Players.ChildAdded:connect(onPlayerEntered)
Would this work?
You will want to use the ClickDetector and make sure you add Leaderstats. Unfortunately without a attempt at your script, I will not help you.
Closed as Not Constructive by Sublimus, HexC3D, TheeDeathCaster, and Articulating
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?