Then create pvp ‘bool value’ for each player once joined with the same name, then for changing the value you can use remote events as I stated above and for the last thing, all you have to do is checking the value with an infinite loop.
Look im not a very good scripter. All im asking here is to make the health 200 if pvp == true. Is it this complicated??
I found a way!
local pvp = false
local humanoid = game.Players.LocalPlayer.Character.Humanoid
if pvp == false then
humanoid.Health = 0
end
How do i make it so the first time i click pvp it says pvp: on and the next time i click it it says pvp: off?
Please for the love of memes dont change the health on the client, that is a bad idea in general of itself @XxJonnyDaBestxX
Are you handling the pvp system on the client? If so, thats a bad idea. Handle the remote events/clicking on and off pvp on client with remote events, and handle important things like checking pvp status on players and so on the server.
But how? Im horrible at scripting so you cant tell me all of this stuff that i dont even understand
Thats why the developer hub exists, although it may not answer all questions, it will certainly help you find some:
Will describe how client and server works (Important):
Will describe remote events and how they’re used:
EDIT: Handling on the client with important things is a bad idea, it can get easily exploited.
also I think I am handling it on the client.
But it would work right? It should.
It’ll only technically show on the client so actually, no
I recommend reading the first link to understand.
Heres a basic jist if you’re lazy like me:
Client can only see things they see on their computer. Thats why effects are done on the client so other clients can see what they’re seeing. Basically, one way window.
Server can see all but cant see exactly on what clients do what. Any client sided changes won’t be seen on the server. Thats why remote events exists, they help communicate messages.
I do know but my question is since i figured this out, how do I make it so when I click it turns pvp on then when I click again it turns pvp off?
I have this script rn:
local pvp = false
local humanoid = game.Players.LocalPlayer.Character.Humanoid
if pvp == false then
game.StarterGui.Pvp.Button.TextLabel.Text = "Pvp: Off"
humanoid.Health = 100000000
end
if pvp == true then
game.StarterGui.Pvp.Button.TextLabel.Text = "Pvp: On"
humanoid.Health = 100
end
It changes the text based on if its on/off, how do i change if its on/off by clicking?
Here is my suggestion (you can use above posts if you want):
Why don’t you check if the player has PVP on before hurting them? You can fiddle with your weapons code to do that. Though i dont know what your weapons code looks like, I’ll give you this as an example:
local Players = game:GetService("Players")
function HurtPlayer(Humanoid)
local Target = Players:GetPlayerFromCharacter(Humanoid.Parent)
if Target and not Target.PVP.Value then return end
--damage code below
end
This is frustrating me. I’ll come check your ideas tomorrow. Please don’t make them complicated.
Don’t put anything in the Character like BoolValues, you will easily have it exploited. Instead, use a different place to put it in or a table or etc.
It’s a Player, Darlin. The bool value should be parented from the moment they join. Plus, the code is checked in a server script.
local Players = game:GetService("Players")
local TargetPlayer = Players:GetPlayerFromCharacter(Model)
--Returns a Player from the Character, if it is a character.
Nevermind, I misread. Sorry about that.