I need help with a script that seems pretty logic to me

hi people,
Im making a sort cash system the current script is a server script and every name is correct and checked 10 trillion times, this thing seems logic to me but it doesnt seem to work:

local m = game.ReplicatedStorage.Money
local m2 = game.ReplicatedStorage.Multiplier



script.Parent.DoeDan.OnServerEvent:Connect(function(plr)
	while wait(0.5) do
		if m and m2 then
			m.Value -= 10
			m2.Value = 2
		end
	end
end)

i want to subtract 10 money from the intvalue as seen in the script, its not working and i did some debuging and found out not event this worked:

local r = script.Parent.DoeDan

script.Parent.Activated:Connect(function()
	print("FIRREFRGGGT")

end)

its a text button… Not functioning as it should, this is the hiarchy:

this is breaking my brain and any time/ help is appreciated

2 Likes

Well based on what you said in your local script it does not fire the event You’ll need to r:FireServer() and remote events (Thedoedone one) must be placed in replicated storage

1 Like

Already tried that before, not working so i thought this worked and then i tried maybe the dev forum would help

It might not be working because you are checking when the gui in starter gui is activated, and that never activates. So you need to define the gui you want to check through playerGui.

The gui from starterGui are replicated into PlayerGui so you don’t have to worry about how to name them. The only difference is that player gui is what the player can interact with so you can hook up events and what not.

Well I know for sure remote events wont work if u place them inside of a local script so the first step would be to put in replicated storage and modify your code

Okay let me try in a bit [ char limit ]

https://gyazo.com/51725e14882c5b27d77625dcf5222c5c

It worked for me, it might just be an issue with your remote event. Test out the script I made in a new baseplate. Add a screenGui to starterGui and a textbutton under it. Then in stater player scripts add this:

local gui = player.PlayerGui:WaitForChild("ScreenGui").TextButton

local testGui = game:GetService("StarterGui"):WaitForChild("ScreenGui").TextButton

gui.Activated:Connect(function()
	print("activated")
end)

testGui.Activated:Connect(function()
	print("activated test")
end)

Quick tip: try using " ```" before u give a script to make it as a script, thought saying that. That scriptu gave me did not work, yeah. Studio broken or something

What part did you try? The remote event in repstorage or actually firing the event?
Does this print?

print("FIRREFRGGGT")

that doesnt print, the whole thing just doesnt work

Right, so after the print add the r:FireServer() to call the remote event.

Bro, how do you want to do that when he cant even recognise the thing is clicked on?

Oh my sorry brain read what it wanted…
But can you show the buttons properties?

found out that active was turned off :skull:

that was the only way i could get it not to work

Well good luck with your game!

thanks mate, im making this out of boredom, but im sure to work hard on it

1 Like