Im trying to increase the Health/MaxHealth values through a GUI Button, but I dont really understand serversided stuff very well. I keep getting FireServer is not a valid member of Script "ReplicatedStorage.Heal_Me".
How do I set this up
Im trying to increase the Health/MaxHealth values through a GUI Button, but I dont really understand serversided stuff very well. I keep getting FireServer is not a valid member of Script "ReplicatedStorage.Heal_Me".
How do I set this up
You dont need a localscript to fire to a serverscript to change a players health. Because your character is client-sided, if you change any property of your humanoid it will change to the whole server. Ditch that remoteevent and serverscript and just make it really simple. Something like this: (Place this in a localscript inside the button)
local player = game.Players.LocalPlayer
local button = script.Parent
repeat
char = player.Character
wait()
until char
local hum = char:FindFirstChildWhichIsA("Humanoid")
button.Activated:Connect(function()
hum.MaxHealth = hum.MaxHealth + 100
hum.Health = hum.Health + 100
end)
It would be also great to check the devwiki: They got examples and tutorials on how to use and make things.
https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
Now if you put this script inside a button, you wont see anything change because the players health changes with the maxhealth. If you remove line 11 you would see that the maxhealth changes
Wait i just realized, im wrong, ignore this whole post!!!!
yeah, health isnt client sided I dont think. I made it my self, thanks for the help though!
Made Remove Event in Replicated Storage named "healthier"
Made a Script in ServerScriptService named "healthier" code:
game:GetService("ReplicatedStorage").healthier.OnServerEvent:Connect(function(Player)
Player.Character.Humanoid.MaxHealth = Player.Character.Humanoid.MaxHealth + 10
end)
and finally made Button and a child localscript with this code:
script.Parent.MouseButton1Click:Connect(function()
game:GetService("ReplicatedStorage").healthier:FireServer()
end)
RemoveEvents were confusing at first, but actually they are pretty easy. Feel free to ask for explanations
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Is this going to apply to all players or just your player? Also, are you trying to make it like an armor system? So like when you go and pick up the armor, it gives you more health?
Just the player that presses the GUI, this is just for experimenting, so I might do that, but first I want to first try this out so I understand how it works
Alright.