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

Change a Gui only when player is touching a brick?

Asked by 10 years ago

Alright, so I have a brick that has a Script in it and what I need this script to do is change a Players Money Gui but ONLY when the Player is touching the Brick. So far it has not gone right. I am not sure whats wrong but it is just not working. Also there is an error on one of the End's. Here it is:

local money = game.Workspace.player.PlayerGui.MoneyGui
local paybrick = script.Parent


function payperson(player)
    repeat
    if player.PlayerGui.Job.Jobname.Text == "Cashier" then 
        MoneyGui.Value = 0 + 10 
        wait(7)
    else
        end
    until(player.touched == false)
    end
end --this line says '<eof>' expected near 'end' and I have no idea what an <eof> is.

script.Parent.touched:connect(payperson)

So it should not be that hard of a Script but I can not figure it out. Also in the MoneyGui is another script that should keep the players money so as the player makes money the Gui shows that without the player having to reset, not sure if it would help but here is that script:

local money = script.Parent
local playermoney = script.Parent.Value

while true do
    player.PlayerGui.money.Text = playermoney.Value .. '$'
    wait(0.1)
end

No errors with this one as far as I know. I really need some help as to why the first script wont work though. I have no idea what an <eof> is and I am just clueless as to what is wrong. I am not very "Advanced" I know the bare bone basics and I am trying to push what I know with this game.

1 answer

Log in to vote
0
Answered by 10 years ago

"<eof> expected near end" literally means that the end of the file should be where the final end is. Basically, you just need to get rid of that end. Like this:

local paybrick = script.Parent

paybrick.Touched:connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        local money = player:WaitForChild("PlayerGui").MoneyGui
        repeat
                if player:WaitForChild("PlayerGui").Job.Jobname.Text == "Cashier" then 
                    money.Value = money.Value + 10 --You need to point to the value that is in the MoneyGui here.
                    wait(7)
                else return
            end
        until paybrick.TouchEnded:wait()
    end
end)

Please up vote my answer and accept it if it helped you. :) (Note that I'm not sure if this will work.)

0
You helped by explaining the <eof> part but the code still does not work. CrispyBrix 113 — 10y
0
Well, for the money variable, you haven't identified player and you need to use Players instead of Workspace. I've edited the script, see if it works. Spongocardo 1991 — 10y
Ad

Answer this question