Function doesn't work for some reason

I fixed that problem already, on the script there are currently no errors.

1 Like

What is the goal? Is it to play the sound?

Yeah, the goal is to play the sound when a GUI button is pressed, but the function command isn’t working for some reason, so the contents in the function command (which play the sound) cannot be used.

Instead of dealing with a GUI, why don’t you just do tool.Activated:Connect(function()?

The mouseclick is used for something else. And if both scripts overlap, it won’t work, since the mouseclick is basically like a self-destruct button for the object.

Can you show a video if possible to see what’s going rn? Or send a file?

Yeah hold on something broke and I need to fix it back so that it’s in the same state like the start of this post

I didn’t find a solution to revert the tool back but FoxBox found a solution to the function glitch, if he wants he can post the solution here

you can do:

  1. Put ScreenGui with the button in the StarterGui, set ScreenGui Enabled to false, rename
    image

  2. in the tool make two scripts: local and server

  3. Add RemoteEvent to the tool, name it RemoteActivate
    image

local script:

local tool = script.Parent

local player = game.Players.LocalPlayer
local InteractGUI = player.PlayerGui:WaitForChild("InteractGUI")

tool.Equipped:Connect(function()
	InteractGUI.Enabled = true
end)

tool.Unequipped:Connect(function()
	InteractGUI.Enabled = false
end)

InteractGUI.InteractButton.MouseButton1Click:Connect(function()
	tool.RemoteActivate:FireServer()
end)

Server script:

local tool = script.Parent

local reloadTime = 24
local Debounce = false

tool.RemoteActivate.OnServerEvent:Connect(function()
	if Debounce == false then
		Debounce = true
		-- YOUR CODE HERE
		wait(reloadTime)
		Debounce = false
	end
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.