Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Transparency=0 Script Dosn't Work, I Don't Know Where To Go From Here, Would You Please Help?

I don't know what I'm doing here, please help! I would like for when script.Parent.Transparency = 0, the player earns cash every wait(2).

local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local cash = Instance.new("IntValue")
cash.Name = "Cash"

script.Parent.Transparency = 0 
while true do
		wait(2)
		cash.Value = cash.Value + 25
end

3 comments

0

what

0

um u didnt even set the parent of the IntValues lol

0

@EXpodo1234ALT The parent does not have to be set in order to change the property of objects. Now, if he wants to make a leaderboard, then he'd have to put it into the player.

1 answer

✓ Accepted answer

Hello,

You would like to do a script that if the part's transparency is == 0 then you would like the player's cash to go up by 25, from waiting 2 seconds.

First of all, let us look at your original code:

local stats = Instance.new("IntValue")

The first line of the code is incorrect. The reason is because there is no specific place for the IntValue to be parented of, so the leaderstats is not the Players.

Also, the cash instancing is also incorrect for the same reason, it is inserted not into leaderstats.

Since this is a server script, LocalPlayer is not a variable that can be used, since this is dealing for the server, and not locally for the client. In that case, we'd need a function that runs whenever the player has joined the game, so then we are able to create a variable for the local player.

So, the correct code would be:


game.Players.PlayerAdded:Connect(function(player) -- 'player' can be identified as an argument for LocalPlayer, since this is in a server script.

local stats = Instance.new("Folder")
stats.Name = 'leaderstats'
stats.Parent = player

local cash = Instance.new("IntValue")
cash.Name = 'cash'
cash.Parent = stats

local part = workspace.Part -- better to have the part in the workspace since it is visible to the player

while part.Transparency == 0 do
	wait(2)
		cash.Value = cash.Value + 25
end
end)

-- Thank you,

Creeperthekid32

Social Media if erroring occurs:

Roblox: Creeperthekid32

Twitter: @creeperthekid32

Discord: Creep#7611

2 comments

0

Not sure why, but it doesn't seem to be working.

0

Is the part in the workspace? I had mentioned that for a reason.

This discussion is preserved as it was. New answers, comments, and votes are closed.