ive made this script where you touch a brick and it makes your leaderstats go to 1. i need to put this in a gui but i dont know how this is the script.

local button = script.Parent

function onTouched(hit) if hit ~= nil then local character = hit:FindFirstAncestorOfClass("Model") if character ~= nil then local player = game.Players:GetPlayerFromCharacter(character)

        if player ~= nil then
            local stats = player:WaitForChild("leaderstats")
            local stat = stats:FindFirstChild("Stage")
		
            if stat ~= nil then
                stat.Value = 1
                --Teleport back to stage 1
	end
        end
    end
end

end

button.Touched:Connect(onTouched)

8 comments

0

Use the .MouseButton1Click signal for GUIButton Objects; you'll need to use a LocalScript to operate a UI element, as it's a Locally orientated Instance. This is a drawback since the Server is no longer handling the modification of the Leaderstat, therefore the adjustment is ignored due to FE. You'll need to use a RemoteEvent.

0

so how would the script be?

0

because ive not really done scripts but ive been looking for a long time for a restart obby gui

0

This is not a request site, you can find out how to program it by looking up the information mentioned above in the Developer Wiki: .MouseButton1Click, RemoteEvent.

0

ok

0

would i have to add something like if mousebutton1click then leaderstats.=1 or something like that cuz ive never done scripting

0

That is not constructive crybaby cause this will cost you lose rep

0

Please just put all your code in a codeblock. Stop trying to give this guy a hard time