ok so i have an apple(meshpart) in a folder in workspace and when i click on it, it is supposed to heal the player by 10 but it does absolutely nothing it doesn't even print
localscript:
script.Parent.ClickDetector.MouseClick:Connect(function() print("clicked") game.ReplicatedStorage.HealingEvents.SmallHeal:FireServer() print("sent") script.Parent:Destroy() end)
script:
game.ReplicatedStorage.HealingEvents.SmallHeal.OnServerEvent:Connect(function() game.Players.PlayerAdded:Connect(function(plr) local hum = plr.Character.Humanoid game.Workspace.Sounds.Crunch:Play() hum.Health = hum.Health + 10 end) end)
Exact Directory of the apple is game.workspace.PreAlphaApples.Apple but i dont think that matters
1.) Local scripts won't work if it's a descendant of the workspace
2.) Why are you putting a PlayerAdded event in the function connected to OnServerEvent? The first argument of OnServerEvent is always the player who fired the event.
3.) You know, you could've done this all in a server-sided script:
-- server-sided script inside the apple script.Parent.ClickDetector.MouseClick:Connect(function(player) local char = player.Character or player.CharacterAdded:Wait() local hum = char:WaitForChild('Humanoid') hum.Health = hum.Health + 10 workspace.Sounds.Crunch:Play() script.Parent:Destroy() end)