Script in workspace:
local humanoid = game.Workspace.Speler.Humanoid game.Players.PlayerAdded:connect(function(player) player = player end) humanoid.MaxHealth = 0 humanoid.Health = 0 humanoid.HealthChanged:connect(function(health) local players = game:GetService("Players") humanoid.Parent.Head.Touched:connect(function(otherpart) if otherpart.Name == "Handle" then local player = otherpart.Parent.Parent local replicatedstorage = game:GetService("ReplicatedStorage") local remote = Instance.new("RemoteEvent", replicatedstorage) remote:FireClient(player) end end) end)
LocalScript in startergui:
local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent") remote.OnClientEvent:connect(function() local health = game.Workspace.Speler.Humanoid.Health game.Workspace.Speler.Humanoid.MaxHealth = 100 game.Workspace.Speler.Humanoid.Health = 100 end)
What i wanted to do was that if a player damages a humanoid, the damage would only be visible to the client. It did work fine with 1 player in Roblox Studio, but it doesn't work in the localserver.
local humanoid = game.Workspace.Speler.Humanoid game.Players.PlayerAdded:connect(function(player) player = player end) humanoid.MaxHealth = 0 humanoid.Health = 0 humanoid.HealthChanged:connect(function(health) local players = game:GetService("Players") humanoid.Parent.Head.Touched:connect(function(otherpart) if otherpart.Name == "Handle" then local player = otherpart.Parent.Parent.Parent print(otherpart.Parent.Parent.Parent.Name) local replicatedstorage = game:GetService("ReplicatedStorage") local remote = Instance.new("RemoteEvent", replicatedstorage) remote:FireClient(player) end end) end)
At line 13, the part where i wanted to print the otherpart.Parent.Parent.Parent. It gaves in the output 'workspace'. Tht item is in the starterpack, backpack when the game starts. Why does it print workspace?