Disclaimer : This Is A Repost Cause On The Other One NO One Answered
Hello, I'm A New Beginner In Scripting And I've Been Making A Simulator game And I've Been Wondering If Anyone Could Make me a Script Which Give 500000 Of The Technology To Specific Players And I Cant Do It So If Anyone Can Do It I Will Be Really Happy. Thanks! btw Heres The Script..
local db = false local tool = script.Parent repeat wait() until tool.Parent.Parent:IsA("Player") local plr = tool.Parent.Parent local character = plr.Character tool.Activated:Connect(function() if not db then db = true plr.leaderstats.Technology.Value = plr.leaderstats.Technology.Value + 1 wait(1) db = false end end)
Since you've already got your activated event, you can just put the Character variable inside the Activated event using script.Parent.Parent
to get the character, the reason for this is because the Tool is going to be inside the player's Character while they are using the Tool right? So then you can use the Players:GetPlayerFromCharacter to then get the player from the player's Character.
local db = false local tool = script.Parent tool.Activated:Connect(function() if not db then db = true local Character = script.Parent.Parent local Player = game.Players:GetPlayerFromCharacter(Character) Player.leaderstats.Technology.Value = Player.leaderstats.Technology.Value + 1 wait(1) db = false end end)
To make it so it gives 500000 Technology to a specific player, you can make an if statement to check if the Player.Name or Player.UserId is equal to your name/UserId, depending on what you want, I'd probably recommend using UserId. If you want multiple players to also have access to this, then you can also use a table and insert the players' UserId's into the table then use table.find()
to check if their UserId is in the table.
First Example:
local db = false local tool = script.Parent tool.Activated:Connect(function() if not db then db = true local Character = script.Parent.Parent local Player = game.Players:GetPlayerFromCharacter(Character) if Player.UserId == 283818237 then -- Put your UserId here Player.leaderstats.Technology.Value = Player.leaderstats.Technology.Value + 500000 else Player.leaderstats.Technology.Value = Player.leaderstats.Technology.Value + 1 end wait(1) db = false end end)
Second Example(Table):
local List = {283818237} -- Put UserId's here local db = false local tool = script.Parent tool.Activated:Connect(function() if not db then db = true local Character = script.Parent.Parent local Player = game.Players:GetPlayerFromCharacter(Character) if table.find(List, Player.UserId) then Player.leaderstats.Technology.Value = Player.leaderstats.Technology.Value + 500000 else Player.leaderstats.Technology.Value = Player.leaderstats.Technology.Value + 1 end wait(1) db = false end end)
Sorry if this was a bit much, lol