Hey everyone! So recently I’ve been working on a disease system that randomly infects you and gives you a certain disease by chance. Now, the problem is, how do I get the tool to cure the one getting the cure?
What do you want to achieve? Keep it simple and clear!
As said before, I need to get the tool to cure whoever is infected.
What is the issue? Include screenshots / videos if possible!
The issue is I do not know how to get it to cure the other person, and remote events haven’t been working very well for this.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried client to server to client, client to server, but neither worked. There wasn’t anything related to this on the Developer Hub that I could find.
Below is the code, I have three scripts, which I will list which is which.
Local Script (In StarterPlayerScripts)
local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() wait(10) local Cough1Copy = game.ReplicatedStorage.Cough1:Clone() Cough1Copy.Parent = Character.Head local Cough2Copy = game.ReplicatedStorage.Cough2:Clone() Cough2Copy.Parent = Character.Head game.ReplicatedStorage.Cure1two.OnClientEvent:Connect(function() print("RecievedClient") wait(4) ColdOn = false end) while true do local newRandom local oldRandom = newRandom local chosenDisease local oldchosenDisease= chosenDisease if TuberOn == true then for count = 1, 60 do wait(1) Character.Humanoid.Health = Character.Humanoid.Health - 1 Character.Humanoid.WalkSpeed = Character.Humanoid.WalkSpeed - .1 end TuberOn = false elseif FluOn == true then for count = 1, 300 do wait(1) Character.Humanoid.Health = Character.Humanoid.Health - .1 Character.Humanoid.WalkSpeed = Character.Humanoid.WalkSpeed - .005 end FluOn = false elseif ColdOn == true then for count = 1, 30 do wait(8) Cough1Copy:Play() Character.Humanoid.WalkSpeed = Character.Humanoid.WalkSpeed - .4 wait(8) Cough2Copy:Play() end ColdOn = false end do repeat newRandom = math.random(20, 30) wait() until newRandom ~= oldRandom end do repeat chosenDisease = math.random(0, 100) wait() until chosenDisease ~= oldchosenDisease end wait(newRandom) print(chosenDisease) TuberOn = false FluOn = false ColdOn = false if chosenDisease >= 90 then print("Tuberculosis!") TuberOn = true elseif chosenDisease >= 85 then print("Flu!") FluOn = true elseif chosenDisease >= 60 then print("Cold!") ColdOn = true elseif chosenDisease >= 0 then print("None!") end end
Local Script (In the tool in StarterPack)
local tool = script.Parent local Debounce = true tool.Handle.Touched:Connect(function(hit) local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) if Player and Debounce == true then Debounce = false game.ReplicatedStorage.Cure1:FireServer(hit) wait(1) Debounce = true end end)
Server Script (In Server Script Service)
game.ReplicatedStorage.Cure1.OnServerEvent:Connect(function(firing) game.ReplicatedStorage.Cure1two:FireClient(firing) print("RecievedServer") end)