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

how do I subtract a textlabel size using a clickdetector ?

if script.Parent.Parent.A.Transparency==1 then
game.StarterGui.ScreenGui.h.Text = game.StarterGui.ScreenGui.h.Text - "20"
game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").hunger.Size =
UDim2.new(0,game.StarterGui.ScreenGui.h.Text,0,0)

...is what i used

2 comments

0

You said your using a click detector? Is this clicking a part or a text button?

0

part

1 answer

✓ Accepted answer
local player = game:GetService("Players").LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local hungerGui = playerGui:WaitForChild("ScreenGui")
local hunger = hungerGui:WaitForChild("hunger")

local a = script:FindFirstAncestor('A')

a.MouseButton1Click:Connect(function()
    hungerGui.h.Text = tostring((tonumber(hungerGui.h.Text) - 20))
    hunger.Size = UDim2.new(0,tonumber(hungerGui.h.Text),0,0)
end)

1 comment

0

Your code is going to do something really odd but alright... this is what I could fix up from your lack of description so if it breaks it’s up to you lad. You can’t use a ClickDetector anywhere else but within workspace; DetectorObjects aren’t meant for GUIs, you can simply listen for a Click through the .MouseButton1ClickSignal.

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