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

why does this work in studio, but not player?

while true do
	script.Parent.Text = "cost:" ..script.Parent.textval.Value .." cps + .1"
	wait()
end

i have others like this, but the others dont have a decimal point. so i took of the decimal, and it didnt work. theres nothing in the output about it. why do the others work, but this one doesnt?

this is just the text script, heres the upgrade script:

playerWhoClicked = game.Players.LocalPlayer
price = 15
increase = 3
script.Parent.MouseButton1Down:connect(function()
	
    if playerWhoClicked.Character:FindFirstChild("Humanoid") then
        local playerWhoClicked = game.Players:GetPlayerFromCharacter(playerWhoClicked.Character)
        if playerWhoClicked.leaderstats.Cookies.Value >= price then
        playerWhoClicked.leaderstats.Cookies.Value = playerWhoClicked.leaderstats.Cookies.Value - price
        price = price + increase
script.Parent.textval.Value = script.Parent.textval.Value + increase
        playerWhoClicked.leaderstats.Cps.Value = playerWhoClicked.leaderstats.Cps.Value + .1
            while wait(10) do
                playerWhoClicked.leaderstats.Cookies.Value = playerWhoClicked.leaderstats.Cookies.Value + 1
            end
        end
    end
end)

this will give me .1 cps, subtract ten cookies, and then start giving me cookies.this script works fine, it the text one that has the issue.

7 comments

0

There shouldn't be a space in between "cost"..script.Parent.textval.Value.." cps + .1". So no spaces in between the double decimals. Add the spaced in the string values instead.

1

The whitespace between string concatenations won't matter.

0

the spacing doesnt matter, i have one EXACTLY like this, and it works. this one is just glitching up for some reason. i thought that somebody might knwo a fix

0

I don't see how this wouldn't work. Mind showing the rest of the script?

0

sure

0

Where is the first part of the script located? It it's below the wait(10) loop, then that may be the issue.

0

these are two scripts, both inside of an image button, inside of a frame, inside of a screen gui, inside of starter gui, inside of game

1 answer

I just saw your issue. Is this a GUI or a ClickDetector? If it's a GUI, remove line 7 since you're referencing playWhoClicked later as an actual Player. If it's a ClickDetector, change the event on line 4 to MouseClick, and put a parameter inside the function, with playerWhoClicked, and remove line 7. Any questions?

4 comments

0

Good one

0

its gui, so i removed line seven. but that part isnt the issue. its the first script. the text just doesnt display in roblox player, but it does in studio

0

wait, fixed it. i just found theit works in studio but not in player section. i had to change one of the scripts to server. but the other local ones work. it stumps me, but i fixed it

0

Alright

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