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

What is the best way to refer to something from a local script in this situation?

Asked by
SuperFryX 130
8 years ago

I am creating a Battle Mech that Players can ride. When you sit in the seat of it, it gives you a local script that basically allows you to press certain keys in order to fire certain weapons on the mech.

Problem is, I can't refer to the Mech that the Local Script was previously in before it got put into the Player. Do I have to assign something like random ID's to each mech so I know which mech to refer to or is there a simpler way?

1 answer

Log in to vote
0
Answered by 8 years ago

this should work ...

seated = {}
bool = true
script.Parent.Touched:connect(function(plr)
    if plr.Parent:FindFirstChild("Humanoid") and 
         game.Players:FindFirstChild(plr.Parent.Name)
        then
    plr.Parent.Humanoid.Seated:connect(function(goodgod)
        if bool then
            bool = false
       seated[1] = game.Players:FindFirstChild(plr.Parent.Name)
        print(seated[1])
--[[ This is where you should do like ... local clone = script.LocalScript:clone()   clone.Parent = plr.Parent ... and that should work if theres a local script inside the script and the script is in the seat .....]]
        plr.Parent.Humanoid.StateChanged:connect(function(PlayerIsUp)
            if not bool then
                 seated[1] = nil
--[[ This is where you would do ... clone:Destroy() ... ]] 
                wait(2)
                bool = true
            end
        end)

        end
        end)
    end
end)
--[[ Made by Angels_Develop   .. Sorry if you dont like the copywrite but I took a few minutes to write this out so just keep it ... ]]
Ad

Answer this question