Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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
0
what User#19524 175 — 6y
0
um u didnt even set the parent of the IntValues lol User#23365 30 — 6y
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. EzraNehemiah_TF2 3552 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

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

0
Not sure why, but it doesn't seem to be working. Darkcraft10 20 — 6y
0
Is the part in the workspace? I had mentioned that for a reason. Creeperthekid32 70 — 6y
Ad

Answer this question