Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[ANSWERED] May I get help with turning a LocalScript code into a Script?

I was making a tool and it is composed of Tool>LocalScript and Handle>BillboardGUI>TextLabel with the BillboardGUI being named "Help". The concept was a little "In-Danger Flare" and for the Handle part to be put wherever it is last positioned, however I didn't know the difference between a LocalScript and a Script, so whenever I clicked, it was only me who was able to see the part that was spawned. I took the chance of putting the whole code into a Script, but, of course, it didn't work. I think the problem is with my 'local player = game.Players.LocalPlayer', but I'm not sure and I don't know my mistake since I'm currently new to coding. I basically need help in turning this LocalScript into a Script. Thank you!

local tool = script.Parent
local player = game.Players.LocalPlayer

function onActivation()
    local ask = tool.Handle:Clone()
        ask.Parent = workspace
        ask.Help.Enabled = true
        ask.Anchored = true
        tool:Destroy()
        ask.CFrame = ask.CFrame*CFrame.new(0,0,0)
        ask.Help.TextLabel.Text = player.Name.. " needs help!"
    wait(30)
        ask:Destroy()
end
 
tool.Activated:Connect(onActivation)

Here are a few visuals:

  • Composition of the tool:

https://prnt.sc/su6b6x

  • How the tool works:

https://gyazo.com/e4673bfbea7f114fddd3e7d3f99b6763 -- It works fine with the LocalScript, but yeah, I'm the only one who can see it.

Sorry if this question seems dumb, I'm a bit new to this domain.

1 answer

If u want to get the player in a script put in the tool then u should never use local player as that wont work, instead since u have to activate the tool for the help the tool will be equipped so the tool will be in the character's model so put this line in ur script to get the player

local tool = script.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)

2 comments

0

Also only u can see it if it is a local script

0

Thank you very much, I adjusted a few things, but it worked. You really helped so thank you. :)

This discussion is preserved as it was. New answers, comments, and votes are closed.