Disease System and Cures

okay so basically, it does “work” the effects of the cold disease should be inside of the place where it says

if disease == "Cold" then
1 Like

It still doesn’t work.

The code:

local collectionservice = game:GetService("CollectionService")
local virusbindable = game.ReplicatedStorage.VirusBindable




virusbindable.Event:Connect(function(disease,plr)
	if disease == "Cold" then
		local Cough1Copy = game.ReplicatedStorage.Cough1:Clone()
		Cough1Copy.Parent = plr.Character.Head
		
		local Cough2Copy = game.ReplicatedStorage.Cough2:Clone()
		Cough2Copy.Parent = plr.Character.Head
		
		print("GotCold!")
		wait(8)
		Cough1Copy:Play()
		plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed - .4
		wait(8)
		Cough2Copy:Play()
	end
	if disease == "remove disease" then
		collectionservice:RemoveTag(plr,collectionservice:GetTags(plr))
	end
end)

What is Cough1Copy and Cough2Copy?

1 Like

They are coughing sounds. They’re just another addition to the cold.

your waiting 8 seconds to make them cough? also, are there errors being printed in the output?

1 Like

Yeah, I make them wait 8 seconds. There are no errors being printed.

is “GotCold!” being printed? and why dont you add a print after the first wait(8) and see if it prints after eight seconds.

1 Like

It originally was. Now that I added a wait after the first 8 seconds, I’m getting this now:

change plr.Character.Head to plr.Head, plr is the players character whom got hit.

2 Likes

Still throws this out.

okay, so your going to want to change virusremote:FireServer("Cold",hit) to virusremote:FireServer("Cold",hit.Parent)

1 Like

Switched it, still shows this.

Handler Code:


virusbindable.Event:Connect(function(disease,plr)
	if disease == "Cold" then
		local Cough1Copy = game.ReplicatedStorage.Cough1:Clone()
		Cough1Copy.Parent = plr.Head
		
		local Cough2Copy = game.ReplicatedStorage.Cough2:Clone()
		Cough2Copy.Parent = plr.Head
		
		print("GotCold!")
		wait(8)
		Cough1Copy:Play()
		plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed - .4
		wait(8)
		Cough2Copy:Play()
	end
	if disease == "remove disease" then
		collectionservice:RemoveTag(plr,collectionservice:GetTags(plr))
	end
end)

Local Script (in tool):

local tool = script.Parent
local Debounce = true
local virusremote = game.ReplicatedStorage.VirusRemote

tool.Handle.Touched:Connect(function(hit)
	print("newserver")
	local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		if Player and Debounce == true then
			Debounce = false
			virusremote:FireServer("Cold", hit.Parent)
			wait(1)
			Debounce = true
		end
	end)

inside ofif disease == "Cold" then; add this print(plr)

1 Like

Added, it doesn’t print.
Here it is:

add it before anything else…
3030

1 Like

Still doesn’t work. Weird.

virusbindable.Event:Connect(function(disease,plr)
	print(plr)
	if disease == "Cold" then
		local Cough1Copy = game.ReplicatedStorage.Cough1:Clone()
		Cough1Copy.Parent = plr.Head
		
		local Cough2Copy = game.ReplicatedStorage.Cough2:Clone()
		Cough2Copy.Parent = plr.Head
		
		print("GotCold!")
		wait(8)
		Cough1Copy:Play()
		plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed - .4
		wait(8)
		Cough2Copy:Play()
	end
	if disease == "remove disease" then
		collectionservice:RemoveTag(plr,collectionservice:GetTags(plr))
	end
end)

oh my bad do print(plr.Name)

1 Like

Nope.

virusbindable.Event:Connect(function(disease,plr)
	print(plr.Name)
	if disease == "Cold" then
		local Cough1Copy = game.ReplicatedStorage.Cough1:Clone()
		Cough1Copy.Parent = plr.Head
		
		local Cough2Copy = game.ReplicatedStorage.Cough2:Clone()
		Cough2Copy.Parent = plr.Head
		
		print("GotCold!")
		wait(8)
		Cough1Copy:Play()
		plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed - .4
		wait(8)
		Cough2Copy:Play()
	end
	if disease == "remove disease" then
		collectionservice:RemoveTag(plr,collectionservice:GetTags(plr))
	end
end)

i’m going to open up studio, and try out this stuff really quick for testing. one second

1 Like

it works, here:
Needle Example.rbxl (22.8 KB)
sorry, i was having issues with the touched event, so i made it where when you click it will make your walkspeed slower by 10 after two seconds, however; with some modifications, you can change player.Character parameter in the :FireServer() to be whoever was hit’s character.

let me know if you have any issues, or need any more help :grinning:

1 Like