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

Help me on this script???

Asked by 10 years ago

This script only gives a tool when a player touches it ,but i want everyone to get the tool help?

function onTouched(fish)
    local player = game.Players:playerFromCharacter(fish.Parent)
    local h = fish.Parent:findFirstChild("Humanoid")
    if h~=nil then
        if player ~= nil then 
            game.Lighting.Hammer:Clone().Parent = player:FindFirstChild("Backpack")
            script.Parent:remove()
    end
end
end
script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
1
Answered by
RedCombee 585 Moderation Voter
10 years ago

Line 2: PlayerFromCharacter() is not correct.

Correct:

 local player = game.Players:GetPlayerFromCharacter(fish.Parent)

And by the way, you don't need the humanoid check, because if 'player' checks out, it is guaranteed to have a humanoid.

0
its works for me :3 Anthony9960 210 — 10y
0
It's possible they are aliases for the same thing, but you should be using this one instead. BlueTaslem 18071 — 10y
Ad

Answer this question