Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Healing Item Not doing anything at all?

Asked by
Donut792 216 Moderation Voter
5 years ago

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

0
you can use .MouseClick in a server script Warfaresh0t 414 — 5y
0
no need for a local script or remote event INOOBE_YT 387 — 5y
0
Yeah don't abuse FireServer. User#19524 175 — 5y

1 answer

Log in to vote
3
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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)
0
well dang thank you so much Donut792 216 — 5y
0
If this worked, please accept this answer Rare_tendo 3000 — 5y
0
"Local scripts won't work if it's a descendant of workspace". Not true. Only will when they're a descendant of a player character User#19524 175 — 5y
1
^ yea, I know Rare_tendo 3000 — 5y
Ad

Answer this question