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

How to make ImageButton only add 1 if a certain Image is in it?

local script inside the ImageButton to add 1 if a certain image is in it

local Player = game.Players.LocalPlayer
local PlayerStats = Player:WaitForChild('leaderstats'):WaitForChild('Dice Rolls')

if(BuFoRol.Image = [DecalId = 4888104527]  then
script.Parent.MouseButton1Click:Connect(function()
	PlayerStats.Value = PlayerStats.Value + 1
end)

1 answer

Firstly you want to connect the mouseclick event first before you write any more code:

local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Image == 4888104527 then
    	game.ReplicatedStorage.ChangePoint:FireServer()
	end
end)

this goes in a localscript.

then the server would have to recieve the request via a remoteevent and finally give the player their expected output

game.ReplicatedStorage.ChangePoint.OnServerEvent:Connect(function(Player)
	local PlayerStats = Player:WaitForChild('leaderstats'):WaitForChild('DiceRolls')
	PlayerStats.Value = PlayerStats.Value + 1
end)

3 comments

0

ok so i put your first script on the script i gave and i added a script to script service containing your second script. does'nt work though

0

sorry i mean server storage for the second script

0

Whats the error?

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