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

What Is Added To Make A Server Script Local?

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 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)

7 comments

0

im no expert but maybe try to move all that code into a local script?

0

Thanks for the suggestion but I have already tried this and I believe that it would require more than copying and pasting.

0

So, what player would you want to affect in a game? A random player? The owner? Who knows?

0

well it depends... is the player interacting with something? like clicking a button?

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.

0

As server-side scripts should control the game for all players.

0

Thank you for the answer in the comment section :D

1 answer

✓ Accepted answer

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.

1 comment

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.

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