Yesterday night I sent a request for a heal brick. Someone answered with it might not be going through to the server. In studio AND in a game my character takes damage on screen it looks like it. But it didn't go through to the server thous when I touch the heal brick it doesn't heal unless manually done through the developer console. The damage scripts are done through Local Scripts & the Heal done through a script. Any help is appreciated.
Heal Script:
script.Parent.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then game.ReplicatedStorage.HealEvent:FireServer() hum.Health = hum.Health + 100 end end)
It works if manually done through the dev console & or through current client in studio to change health.
If you have it inside of a Server sided script inside of the brick it will work as Tocuhed can be run through a server script
Assuming the script to damage is going to the server correctly and you're using ROBLOX's Humanoid.Health as a base:
SERVER SIDE ONLY
Server Script under the HealBrick in Workspace
script.Parent.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then hum.Health = hum.Health + 100 end end)
If you wanted to make it so people can't exploit and take the script when its on the client, move it to the ServerScriptService and write:
Server Script under ServerScriptService
workspace.Part.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then hum.Health = hum.Health + 100 end end)
Where "workspace.Part" is the HealBrick
USING REMOTE EVENTS
ServerScript under ServerScriptService
local remote = game:GetService("ReplicatedStorage"):WaitForChild("HealEvent") remote.OnServerEvent:Connect(function(player) player.Character:WaitForChild("Humanoid").Health = player.Character:WaitForChild("Humanoid").Health + 100 end)
Local Script under StarterGui
local player = game.Players.LocalPlayer local remote = game:GetService("ReplicatedStorage"):WaitForChild("HealEvent") workspace.Part.Touched:Connect(function(hit) if hit.Parent.Name == player.Name then remote:FireServer() end end)
Where "workspace.Part" is the HealBrick