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

Help With This Local Script?

Asked by 10 years ago

This works in solo mode but does not work multi Player Any Help?

f = Game.Lighting.FBITalk:clone()

function onTouch(part) 
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil) then
        f.Parent = Game.Players.LocalPlayer.PlayerGui
        script.Disabled = true
    end 
end

script.Parent.Touched:connect(onTouch)

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

LocalScripts won't run except in the player's Backpack, Character, or PlayerGui.

If this script is just inside some button, it won't work.


I would suggest instead revising the function to the following:

if part.Parent then
    local character = part.Parent;
    local player = game.Players:GetPlayerFromCharacter(character);
    if player then
        f.Parent = player.PlayerGui;
        ...
    end
end
0
I Tried This In A Script Before And Still Won't Work Any Other Thoughts? Anthony9960 210 — 10y
0
Have you also made the modification I suggested . . . ? Using LocalPlayer inside of a normal Script object won't work, so you also need to change your code. BlueTaslem 18071 — 10y
Ad

Answer this question