Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Not going through the server?

Asked by 5 years ago
Edited 5 years ago

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.

0
Use remoteevents? RetroGalacticGamer 331 — 5y
0
What do you mean? Notrealac0unt 19 — 5y
0
Like how would I use remote events? Notrealac0unt 19 — 5y
0
When changing a value, you must put it through a remote event and access it. Put a remote event into storage, "healthchanged" or something like that. Make a folder called events, put it into the folder. Then type "game.Replicatedstorage.Events.healthchanged:FireServer()" Then it should work. PS: put the code before "hum.Heath = hum.Health = hum.Health + 100 Masmixel 21 — 5y
View all comments (3 more)
0
I don't think it worked I'll put in edit Notrealac0unt 19 — 5y
0
You do NOT need a remote event for this. namespace25 594 — 5y
0
It will give you another error. Assuming this is not a local script because it shouldn't be. namespace25 594 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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

0
So what you're saying is put the script in ServerScriptService then define the part being touched? Notrealac0unt 19 — 5y
0
no put the server script in the part. Though actually via server script service it would work Protogen_Dev 268 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

0
Nothing is happening nothing in output either. Am I missing something? Notrealac0unt 19 — 5y
0
which of these options are you using? SerpentineKing 3885 — 5y

Answer this question