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

Scripts in ScreenGui not functioning on server?

Asked by 5 years ago

Hi there, scripters! I ran into a problem when trying to make an interface located inside the player's ScreenGui. I am aware that the recent Roblox update forced FE on, but I can't seem to fix this. Any help is appreciated! Both of these scripts are inside of a textbox, inside of a ScreenGui:

Local script- indexes mouse and runs while loop:

wait(1)
mouse = game.Players.LocalPlayer:GetMouse()
speed = game.ReplicatedStorage.Speed:Clone()
speed.Parent = game.Players.LocalPlayer
health = game.ReplicatedStorage.Health:Clone()
health.Parent = game.Players.LocalPlayer

while wait(0.1) do
    for i,v in pairs(script.Parent:GetChildren()) do
        if v.Name == "SpeedButton" then
            v.Position = UDim2.new(0,speed.Value,0,v.Position.Y.Offset)
            script.Parent.Script.Adjust:FireServer(v,speed,health,mouse,"WalkSpeed","MaxHealth",0.17,1.05)
        end
        if v.Name == "HealthButton" then
            v.Position = UDim2.new(0,health.Value,0,v.Position.Y.Offset)
            script.Parent.Script.Adjust:FireServer(v,health,speed,mouse,"MaxHealth","WalkSpeed",1.05,0.17)
        end
        if v.Name == "Done" then
            v.MouseButton1Click:Connect(function()
                script.Parent.Visible = false
                script.Parent.Sound1:Play()
            end)
        end
    end
end

Script- receives fire server and mouse coordinates

click = 0

script.Adjust.OnServerEvent:Connect(function(player,v,value1,value2,mouse,property1,property2,x1,x2)
    v.MouseButton1Down:Connect(function()
        click = 1
        repeat
            wait(0.01)
            if mouse.X > 5 and mouse.X < 190 then
                value1.Value = math.floor(mouse.X/15)*15 + 5
                value2.Value = 190 - (math.floor(mouse.X/15)*15 + 5)
            end
            mouse.Button1Up:Connect(function()
                click = 0
            end)
        until click == 0
        player.Character.Humanoid[property1] = value1.Value * x1 + 10
        player.Character.Humanoid[property2] = value2.Value * x2 + 10
        player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
    end)
end)

I'd also like to mention that this works fine in Studio, but on a server it's broken. It doesn't show any error messages in the output... Thanks!

0
speed & health need to be cloned and parented by the server and not the client Vulkarin 581 — 5y
0
I fixed that, silly mistake. It's still a unresponsive. As far as I know, the local script is firing the message successfully, but the script isn't receiving it. SnazzySpider67 53 — 5y
0
The script is located where? Vulkarin 581 — 5y
0
in a TextBox in ScreenGui. I don't know if the fact that the ScreenGui is in StarterGui is effecting the scripts or not. SnazzySpider67 53 — 5y
View all comments (5 more)
0
Server Scripts don't run in PlayerGui anymore. They run in Play Solo and in Experimental Mode but that got removed. So basically server scripts don't run there anymore. User#19524 175 — 5y
0
Yes as incapaz said you should keep your scripts in ServerScriptService Vulkarin 581 — 5y
0
Okay, I'll try that. Thanks you guys for your help! SnazzySpider67 53 — 5y
0
On the server, it displays an error that says that the argument 'v' is a nil value, I don't know why. SnazzySpider67 53 — 5y
0
Hello? SnazzySpider67 53 — 5y

Answer this question