Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

humanoid modification in filtering enabled not doing anything?

hello all, in my quest to create a game on roblox, (well i'm relatively new to fe), i've come across some issues. namely, the events don't seem to work but there are no errors, if someone could please look upon my code and give me some advice, it would be greatly appreciated.

here is the local side of the code

repStorage.Calls.genericEvent:FireServer("setMaxHealth", 1000)

i also have a print statement to make sure the code has been triggered

print("set max health for "..player.Name)

the statement prints but nothing happens

here is the server side of the code

game:GetService("ReplicatedStorage").Calls.genericEvent.OnServerEvent:Connect(function(player, arg, value)
	local char = player.CharacterAdded:wait()
	local hum = char.Humanoid
	if arg == "setMaxHealth" then
		hum.MaxHealth = value
	end
end

thanks in advance to all!

6 comments

0

did you put player as the first argument for the OnServerEvent

0

the player is automatically assigned to the event as the first arguemtn

0

you could put the local script in starter character scripts then remove the local char = player.CharacterAdded:wait() and replace with local char = player.Character

0

that's not the problem, the localscript is inside of a gui which is in startergui, also that is for the server side of the code which is in serverscriptservice

0

just change the char variable then or maybe do the character added in the local then fire the server and then do the rest of the code with char changed

0

http://prntscr.com/ghvauo that is the localscript, and this is the server script http://prntscr.com/ghvb8y, still not really answering anything

1 answer

✓ Accepted answer

You should be doing :Connect(function() not just :Connect(). This also requires a end) though. Also instead of doing the player.CharacterAdded:wait() in the server script, do it in the local script.

local Player = game:GetService("Players").LocalPlayer

Player.CharacterAdded:Connect(function()
	repStorage.Calls.genericEvent:FireServer("setMaxHealth", 1000)
end)

Then in your server script, do this:

local rs = game:GetService("ReplicatedStorage")
rs.alls.genericEvent.OnServerEvent:Connect(function(Player, arg, value)
	local char = Player.Character
	local hum = char:WaitForChild("Humanoid")
	if arg == "setMaxHealth" then
		hum.MaxHealth = value
		print("Set max health for" .. Player.Name)
		--hum.Health = value
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.