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

What Is Added To Make A Server Script Local?

Asked by 6 years ago

Hello! So I am not asking for the difference between the two but rather asking what needs to be added/removed from a server script to make it a local script? Below is a script I put together in a server script but it does not work because I use <LocalPlayer> which cannot be used in a server script. So how would I make this local?

local Button = script.Parent
Frame = script.Parent.Parent.Parent
EditBlock = script.Parent.Parent.Parent.Parent
OldOven = script.Parent.Parent.Parent.Parent.OldOven
NewOven = script.Parent.Parent.Parent.Parent.Oven

function onClick()
if game.Players.LocalPlayer.leaderstats.Money.Value >= 250 then 
Frame.Enabled = false
EditBlock.Transparency = 1
    local user = game.Players:GetPlayerFromCharacter(game.Players.LocalPlayer.Character) --get player from touching human
    local stats = user:findFirstChild("leaderstats") --Find moneyholder
            local cash = stats:findFirstChild("Money") --Get money
            cash.Value  = cash.Value -250
            OldOven:Destroy()
            NewOven.PartOne.Transparency = 0
            NewOven.PartTwo.Transparency = 0
else
    print("Not enough money!")
end

end


Button.MouseButton1Click:connect(onClick)

0
im no expert but maybe try to move all that code into a local script? TheBishNextDoor -10 — 6y
0
Thanks for the suggestion but I have already tried this and I believe that it would require more than copying and pasting. BunnyFilms1 297 — 6y
0
So, what player would you want to affect in a game? A random player? The owner? Who knows? hiimgoodpack 2009 — 6y
0
well it depends... is the player interacting with something? like clicking a button? kevinliwu1 9 — 6y
View all comments (3 more)
0
Writing LocalScripts vs. regular Scripts requires you to think and write your code in a totally different way. For example, since a LocalScript executes on a client (a player's computer), it makes sense for it to refer to a "local player"; the player that owns the script. However, regular Scripts, which execute on the server, have no concept of "local player" at all. Link150 1355 — 6y
0
As server-side scripts should control the game for *all* players. Link150 1355 — 6y
0
Thank you for the answer in the comment section :D BunnyFilms1 297 — 6y

1 answer

Log in to vote
-1
Answered by 6 years ago

You would have to copy all the code into a local script there is no feature to turn a server script directly into a local one.

0
I do understand that there is no way to convert a script to local script with the click of a button but I am wanting to know what makes this script not suitable/working in a local script when I directly copy and paste it into a local script. BunnyFilms1 297 — 6y
Ad

Answer this question