Hello there, one of my functions have broke randomly without any errors in the console, I’ve tried printing a message and it works but for some reason the variables I defined and the events have stopped working randomly. What the hell happened? There’s meant to have a event respond to a click when the guibutton is clicked and it worked before, but now it doesn’t. I haven’t had any changes done to the script.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")
local ragdollbutton = Player:WaitForChild("PlayerGui"): FindFirstChild("Toggle ragdoll")
local button = ragdollbutton:WaitForChild("ImageButton")
local ClickDetector = Instance.new("ClickDetector")
local Modules = script.Parent:WaitForChild("Modules")
--local Rig = require(Modules:WaitForChild("Rig"))
local Addons = require(Modules:WaitForChild("Addons"))
--local Settings = require(Modules:WaitForChild("Settings"))
local Events = script.Parent:WaitForChild("Events")
local Events_Toggle = Events:WaitForChild("Toggle")
local Events_GuiToClient = Events:WaitForChild("GuiToClient")
local Functions = script.Parent:WaitForChild("Functions")
--local Functions_Ragdoll = Functions:WaitForChild("Ragdoll")
local Functions_RemoteRagdoll = Functions:WaitForChild("RemoteRagdoll")
local Functions_RemoteVelocity = Functions:WaitForChild("RemoteVelocity")
local Variables = script.Parent:WaitForChild("Variables")
local Variables_Ragdoll = Variables:WaitForChild("Ragdoll")
local Variables_RagdollClient = Variables:WaitForChild("RagdollClient")
Toggle Ragdoll (Read last lines)
function ToggleVariables(mode)
if mode == "R" then
Events_Toggle:FireServer("R", not Variables_RagdollClient.Value)
elseif mode == "L" then
Events_Toggle:FireServer("L")
end
end
Events_GuiToClient.Event:Connect(ToggleVariables)
game:GetService("ContextActionService"):BindAction("RagdollToggle", function(_,input)
if input == Enum.UserInputState.Begin then
ToggleVariables("R")
end
end, false, Enum.KeyCode.R)
game:GetService("ContextActionService"):BindAction("ResetHotkey", function(_,input)
if input == Enum.UserInputState.Begin then
ToggleVariables("L")
end
end, false, Enum.KeyCode.L)
button.MouseButton1Click:Connect(function()
ToggleVariables("R")
print ("Ragdoll")
end)
