Why is script affecting the whole server when touching a brick?
Sorry if my wording was wrong with the question title but I have this problem. Basically I'm trying to make the brick that when touched will basically give the player that touched the brick an increase of stats. The only problem is that whenever this happenes it affects everyone in the server giving them and increase of stats.
Attempts
I've tried many attempts alot having to do with filtering enabled.
I tried firing the touched event in the client and then giving the stats in the server
I tried firing the touched event in the server and giving that stats in the client
Recap:
I'm Trying to make a script where the player who touched the brick recieves and increases of stats but its affecting the whole server.
Local Script
local Player = game.Players.LocalPlayer
game.Workspace.DeathPart.Touched:Connect(function(hit)
game.ReplicatedStorage.RemoteEvent:FireServer(hit)
end)
Server Script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player,hit)
Player.Stats.Strength.Value = Player.Stats.Strength.Value + 1
Player.Stats.Armour.Value = Player.Stats.Armour.Value + 1
Player.Stats.Regen.Value = Player.Stats.Regen.Value + 1
Player.Stats.Agility.Value = Player.Stats.Agility.Value + 1
Player.Stats.Stamina.Value = Player.Stats.Stamina.Value + 1
Player.Stats["DiceD-Rank"].Value = Player.Stats["DiceD-Rank"].Value + 1
if hit.Parent:FindFirstChild("Humanoid") then
local ehum = hit.Parent:FindFirstChild("Humanoid")
ehum.Health = ehum.Health - 10
end
end)
Don't mind the health subtracting stuff
Regards, Bl_ueHistory>
