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

How do I make a textlabel change when I step on an item?

Asked by 5 years ago

I have put a TouchInterest and a script inside of a tool that you can pick up.

I want it so that when you pick this tool up, a textlabel changes (it is located: StarterGui > BtmText > Frame > TextLabel )

The code currently doesn't work and I need help with it.

The code right now:

function onTouched(hit)

wait(.5)
game.StarterGui.BtmText.Frame.TextLabel.Text = "You picked a keycard up!"

end

script.Parent.Parent.Touched:connect(onTouched)

Thanks - Frosty

0
Oh also, picking up the item does work but I just need help with the changing of the textlabel :) FrostyPickaxe 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

When you touch an object, you would need to fire a RemoteEvent to the client who stepped on it. And then have a Local Script change the TextLabel to your desired text.

This might get you started...

function onTouched(obj)
    local character = obj.Parent
    local humanoid = obj.Parent:FindFirstChild("Humanoid")

    if humanoid then
        local player = game.Players:GetPlayerFromCharacter(character)
        -- FireEvent(player)
    end

end
script.Parent.Parent.Touched:Connect(onTouched)

https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

Ad

Answer this question