Hi! I have no idea why this code isn’t running. It won’t print at all, nothing is running. It is fairly simple
Code
print("test1")
-- Variables
local Player = script.Parent.Parent
local TemShop = game.Workspace.TemShop
local Button = game.Workspace.TemShop.InteractButton
local ClickDetector = game.Workspace.TemShop.InteractButton.ClickDetector
local ShoppingGui = game.Lighting.ShoppingGui:Clone()
-- Clicked Code
ClickDetector.MouseClick:Connect(function(Player)
Player.Character.HumanoidRootPart.CFrame = TemShop.PlayerShopPosition.CFrame
Player.Character.HumanoidRootPart.Anchored = true
ShoppingGui.Parent = Player.Character.Head
end)
Information on Code
Server Script
Parented to the StarterPlayerScripts
Map1eMoose
(MapleMoose)
November 19, 2020, 11:46pm
#2
Is this a script or a local script and where is it located?
edit. Nvm, you need a local script on the client for the script to run, regular scripts wont run
1 Like
…
Please read the “Information on Code” section.
Put the code in ServerScriptService
Why? This is meant to run on certain players. What would the benefit be? I know how to convert it to .PlayerAdded
.
Minstrix
(Minstrix)
November 19, 2020, 11:49pm
#6
Then you should be using a LocalScript.
Yes but it’s affects are meant to be seen by all.
Minstrix
(Minstrix)
November 19, 2020, 11:49pm
#8
Affects done in StarterPlayerScripts cannot be seen by all.
Skoliage
(Skoliage)
November 19, 2020, 11:50pm
#9
remote events? have you not used that before?
Yes. That is why it is a server script.
Put it in serverscript service it would work perfectly fine as you are receiving the player through the mouse click function
Minstrix
(Minstrix)
November 19, 2020, 11:50pm
#12
For that you’ll need RemoteEvents.
Like, there’s no need for it to run from client to server. ClickDetectors work Serverside I’m fairly sure.
Okay, but can the issue with it being in the PlayerScripts be explained?
Skoliage
(Skoliage)
November 19, 2020, 11:52pm
#15
only local scripts can run on a client, if you want the client to talk to the server, use a remote event.
1 Like
What do you mean? Does the player count as like the client in Instance form?
Minstrix
(Minstrix)
November 19, 2020, 11:55pm
#17
I believe that’s correct, so if you replace your code with the following and put the Script in ServerScriptService, you should get the desired effect.
game.Workspace.TemShop.InteractButton.ClickDetector.MouseClick:Connect(function(Player)
Player.Character.HumanoidRootPart.CFrame = TemShop.PlayerShopPosition.CFrame
Player.Character.HumanoidRootPart.Anchored = true
game.Lighting.ShoppingGui:Clone().Parent = Player.Character.Head
end)
1 Like