How would I be able to make a script so when a player hits a certain amount of time played in the game, they get a different gun?
using
Leaderstats time played.
How would I be able to make a script so when a player hits a certain amount of time played in the game, they get a different gun?
using
Leaderstats time played.
Thanks I will test this a bit later.
I would actually recommend using os.time() from the time they join and saving it to the next time they join.
Hey just one question where do I put the local script
Oh btw
its supposed to be ==
i fixed it anyway.
@SkyWalk1n Hello. I am new to scripting, so I have a question about the script you wrote. Does the script:
if Timeplayed = 50 then
Gun1.Parent = game.Players.LocalPlayer.Backpack
end
add the Gun1 to the backpack? Where would you also put this script (ex. in the ServerScriptService or in the tool itself)? Where would the tool also go?
i just put it in a local script in starter player scripts
and yeah gun 1 goes to backpack
Does the tool still go in the StarterPack, or in ReplicatedStorage or something?
yeah it goes in replicated storage
Okay, thank you. That is useful information.
yeah this does not work. you just said timeplayed is 1
I think it doesn’t work because it should be Timeplayed += 1
yeah it was wrong my i managed to fix it.
and when i add a wait at the begging
theres nothing in the output
I’ll try and recreate it in studio and see if I can get it working.
wait most the scripts that guy sent dont work i fixed them
Okay, I found a solution. Put Micro UZI in replicatedstorage and put the script in serverscriptservice
here is the script:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
leaderstats.Parent = player
local timeplayed = Instance.new(“IntValue”)
timeplayed.Name = “Time” – Name it whatever you want
timeplayed.Parent = leaderstats
while true do
wait(1)
timeplayed.Value += 1
if timeplayed.Value == 50 then
local gun = game.ReplicatedStorage[“Micro UZI”]
local gunclone = gun:Clone()
gunclone.Parent = player.Backpack
end
end
end)
If you want to add more guns, you would need to add the another gun to replicated storage. For an example, I used an ak47 and instead the code for checking the time played would be
if timeplayed.Value == 50 then
local uzi = game.ReplicatedStorage[“Micro UZI”]
local uziclone = uzi:Clone()
uziclone.Parent = player.Backpack
elseif timeplayed.Value == 60 then
local ak47 = game.ReplicatedStorage.Ak47
local akclone = ak47:Clone()
akclone.Parent = player.Backpack