"Struggle" GUI doesn't appear or function properly

So I am making a transfur system for my infection game project and when trying to see it in action. It doesn’t seem to work. Any help?

EDIT: It seems to work rarely, i’ll add my actual script that manages the values.

Here’s my code:

local UserInputService = game:GetService("UserInputService")

local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(0.5, Enum.EasingStyle.Elastic, Enum.EasingDirection.InOut)
local Info2 = TweenInfo.new(0.25, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, true)

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local GrabValue = Character:WaitForChild("Grabbed")

local GUI = script.Parent
local TimesLabel = GUI:WaitForChild("Times")
local Description = TimesLabel:WaitForChild("Desc")

local CurrentStruggle = 0

GrabValue.Changed:Connect(function(Value)
	if Value == true then
		script.Sound:Play()
		GUI.Enabled = true
		local Times = math.random(3,10)
		CurrentStruggle = Times
		
		UserInputService.InputBegan:Connect(function(Input)
			if Input.KeyCode == Enum.KeyCode.Space then
				CurrentStruggle -= 1
				
				TimesLabel.Text = "[ " .. tostring(CurrentStruggle) .. " ]"
				TweenService:Create(TimesLabel, Info2, {Size = UDim2.new(0.205, 0, 0.15, 0)}):Play()
				
				if CurrentStruggle == 0 then
					GrabValue.Value = false
					TweenService:Create(TimesLabel, Info, {TextTransparency = 1}):Play()
					TweenService:Create(Description, Info, {TextTransparency = 1}):Play()
					task.wait(1)
					GUI.Enabled = true
				end
			end
		end)
		TweenService:Create(TimesLabel, Info, {TextTransparency = 0}):Play()
		TweenService:Create(Description, Info, {TextTransparency = 0}):Play()
	end
end)

Control Code:


local AttackCooldownBool = script.Parent:WaitForChild("ArmCooldown")

task.wait(2)

script.Stunned.Value = false
script.Script.Disabled = false

local currenthumanoid = script.Parent.Humanoid
grabbing = false

local function grab(humanoid)
	humanoid.Parent.Actions.Stunned.Value = true
	grabbing = true
	local weld = Instance.new("Weld",script.Parent.HumanoidRootPart)
	weld.Part0 = script.Parent.HumanoidRootPart
	weld.Part1 = humanoid.Parent.HumanoidRootPart
	weld.C0 = CFrame.new(0,0,-1)
	currenthumanoid.WalkSpeed = 5
	currenthumanoid.JumpPower = 0
	currenthumanoid.AutoRotate = false
	local noise = script.Alert:Clone()
	noise.Parent = humanoid.Parent.Head
	noise:Play()
	humanoid.PlatformStand = true
	humanoid.AutoRotate = false
	humanoid:LoadAnimation(script.grabrealize):Play()
	currenthumanoid:LoadAnimation(script.grabstart):Play()
	wait(0.49)
	local grabbedanim = humanoid:LoadAnimation(script.Grabbed)
	local grabberanim = currenthumanoid:LoadAnimation(script.Grabber)
	grabbedanim:Play()
	grabberanim:Play()
	repeat
		wait(0.1)
		humanoid:TakeDamage(2)
		print("damage")
	until humanoid.Health <= 2 or script.Stunned.Value == true or humanoid.Parent.Handler.Infected.Value == true or currenthumanoid.Health <= 0
	grabbedanim:Stop()
	grabberanim:Stop()
	if humanoid.Health <= 3 then
		currenthumanoid.WalkSpeed = 0
		local noise = script.SFX_Bite:Clone()
		noise.Parent = humanoid.Parent.Head
		noise.TimePosition = 1
		noise:Play()
		humanoid.Parent.Handler.Color.Value = script.Parent.Handler.Color.Value
		humanoid.Parent.Handler.dark.Value = script.Parent.Handler.dark.Value
		humanoid.Parent.Handler.e.Value = script.Parent.Handler.e.Value
			
		if script.Parent.Handler.e.Value == true then
			local clone = game:GetService("Lighting").TransfurCone:Clone()
			clone.Parent = humanoid.Parent
		end
		
		humanoid.Parent.Handler.Infected.Value = true
		humanoid:LoadAnimation(script.Bitten):Play()
		currenthumanoid:LoadAnimation(script.Bite):Play()
		if game.Players:GetPlayerFromCharacter(humanoid.Parent) then
			spawn(function()
				local plr = game.Players:GetPlayerFromCharacter(humanoid.Parent)
				game.ReplicatedStorage.INFECTION_REP.EditGUI:FireClient(plr,"text","You're tired, you can't resist anymore.")
				wait(0.9)
				game.ReplicatedStorage.INFECTION_REP.EditGUI:FireClient(plr,"text","You were bitten by a source of anarchy.")
				wait(1.2)
				game.ReplicatedStorage.INFECTION_REP.EditGUI:FireClient(plr,"text","You are becoming one of them.")
				wait(2)
				game.ReplicatedStorage.INFECTION_REP.EditGUI:FireClient(plr,"text","You need to continue this mayhem.")
				
			end)
		end
		wait(5)

	end
	weld:Destroy()
	
	task.spawn(function()
		repeat wait() until script.Stunned.Value == false
		currenthumanoid.WalkSpeed = 18
		currenthumanoid.JumpPower = 40
		currenthumanoid.AutoRotate = true
		humanoid.Parent.Grabbed.Value = false
	end)

	humanoid.AutoRotate = true
	humanoid.PlatformStand = false
	humanoid.Parent.Actions.Stunned.Value = false
	humanoid.Parent.Grabbed.Value = false
	wait(2)
	grabbing = false
end

script.Act.OnServerEvent:Connect(function(plr,type)
	if script.Stunned.Value == false then
		if type == "Attack" and not AttackCooldownBool.Value and grabbing == false then
			currenthumanoid:LoadAnimation(script.Swing):Play()
			AttackCooldownBool.Value = true

			--
			--
			local noise2 = script.SFX_Swing:Clone()
			noise2.Parent = currenthumanoid.Parent.Head
			noise2:Play()
			--
			--

			wait(0.25)
			local rays = 1.1
			local caught = false
			repeat

				local R =  Ray.new(script.Parent.HumanoidRootPart.Position+ Vector3.new(0,0,0), script.Parent.HumanoidRootPart.CFrame.lookVector * 6)
				local v = workspace:FindPartOnRay(R, script.Parent)
				if v ~= nil then
					if v.Parent:FindFirstChild("Handler") and v.Parent:FindFirstChild("Humanoid") and v.Parent ~= script.Parent then
						local humanoid = v.Parent.Humanoid
						if v.Parent:FindFirstChild("Handler").Infected.Value ~= true and humanoid.PlatformStand == false then				
							if v.Parent.Dodge.Value ~= true then
								grab(humanoid)
								humanoid.Parent.Grabbed.Value = true
								caught = true
							end
						end
					end
				end
				if not caught then
					wait(0.1)
					rays = rays - 0.1
				end
			until caught == true or rays <= 0
			wait(2)
			AttackCooldownBool.Value = false
		end
	end
end)
2 Likes

For troubleshooting try putting print statements before you check if that variable or value is what you expect it to be.
For example:

print("x = ", x)
if x < 2 then...

or

print"AttackCooldownBool.Value = ", AttackCooldownBool.Value)

before you check for that value with an if.

It might point you to what section of code is or isn’t being fired, or if the item is nil instead of being what you expect.

I managed to fix it, it had to do with the player.characterAdded event. Thank you for your support!

1 Like

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