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

Why won't my property change gui work?

Asked by 3 years ago

Hello, I'm trying to make a property change gui to easily change some properties of a part for a part of teaching my friends how to script, by observing the properties of a part and changing them. Can anyone help me fix this issue? Thanks! I know this script may be messy, I'm sorry, but I just made this script and I'm not sure where the issue is, it's not outputted. Once again, thank you!:

PartPropertyHandler (ServerScriptService):

local allowed = {"ISkyLordDoge"}

game.Players.PlayerAdded:Connect(function(player)
    for i, v in pairs(allowed) do
        if player.Name == v then
            script.SendProperties:Clone().Parent = player:WaitForChild("PlayerGui")
        end
    end
end)

game.ReplicatedStorage.ChangeProperties.OnServerEvent:Connect(function(player,BrickColorText,Material,Orientation,Position,Transparency)
    for i,v in pairs(allowed) do
        if player.Name == v then
            game.ReplicatedStorage.ChangeProperties:FireAllClients(BrickColorText,Material,Orientation,Position,Transparency)
            game.ReplicatedStorage.CanChange.Value = false
            wait(5)
            game.ReplicatedStorage.CanChange.Value = true
        end
    end
end)

Local Script (In the GUI):

local frame = script.Parent.Frame
local BrickColorText = frame.BrickColor.Text
local Material = frame.Material.Text
local Orientation = frame.Orientation.Text
local Position = frame.PositionE.Text
local Transparency = frame.TransparencyE.Text


script.Parent.Parent:WaitForChild("Toggle").MouseButton1Click:Connect(function()
    if script.Parent.Visible == true then
        script.Parent.Visible = false
    else
        script.Parent.Visible = true
    end
end)

local db = true
for i,property in pairs(script.Parent.Frame:GetChildren()) do
    if property.Changed then
        script.Parent.Submit.MouseButton1Click:Connect(function()
            if game.ReplicatedStorage.CanChange.Value == true and db == true then
                db = false
                game.ReplicatedStorage.ChangeProperties:FireServer(BrickColorText,Material,Orientation,Position,Transparency)
            else
                db = false
                script.Parent.Submit.Text = "Cannot send now"
                wait(2)
                db = true
                script.Parent.Submit.Text = "Send"
            end
        end)    
    end
end     

script.Parent.Cancel.MouseButton1Click:Connect(function()
    script.Parent.Visible = false   
end)

Local Script (In the part I'm trying to change the property of):

game.ReplicatedStorage.ChangeProperties.OnClientEvent:Connect(function(BrickColorText,Material,Orientation,Position,Transparency)
    local part = game.Workspace.PropertyPart
    part.BrickColor = BrickColor.new(tostring(BrickColorText))
    part.Material = Enum.Material.Material
    part.Orientation = Vector3.new(Orientation)
    part.Position = Vector3.new(Position)
    part.Transparency = Transparency
end)
0
Why would you FireAllClients? Seems very useless Raccoonyz 1092 — 3y
0
i adapted that, but im not sure why it has a problem with EnumItem outputted: 20:59:35.409 - material1 is not a valid EnumItem 20:59:35.410 - Stack Begin 20:59:35.411 - Script 'Workspace.PropertyPart.Script', Line 4 20:59:35.412 - Stack End ISkyLordDoge 37 — 3y
0
tried switching to player gui rather than starter gui but still doesnt work :/ ISkyLordDoge 37 — 3y
0
What's the issue? Change line 4 to Enum.Material[Material] to fix the error above. ImTrev 344 — 3y
View all comments (9 more)
0
still doesn't work : / (sorry if i sound rude) ISkyLordDoge 37 — 3y
0
Also the server doesn't have access to PlayerGui. ImTrev 344 — 3y
0
i meant i changed player gui in the local script which was in the gui, btw the material variable is seen as '' (nothing, basically), by any chance, do you know the problem? thanks! ISkyLordDoge 37 — 3y
0
My Questions: 1. Can you see the GUI? 2. What happens when you press the Submit Button? 3. On line 19, is there a child object named "property"? ImTrev 344 — 3y
0
1: I can see the GUI. 2. When I press the submit button, it says 'Cannot Send'. 3. No. ISkyLordDoge 37 — 3y
0
What is the "Changed" after property because it's an event that fires when something is changed so it should connected to a function, and the "CanChange" value must be false because the debounce isn't. ImTrev 344 — 3y
0
I dont know how I didn't spot this before but you need to change the top variables without the .Text because it'll be blank since its taking the text when you first declared them. You need to add .Text to the ends of the parameters in your FireServer. ImTrev 344 — 3y
0
property's class is a TextBox and when it is changed i want to fire the server with parameters of the text which has been changed. also, where could I change the canChange value to false? ISkyLordDoge 37 — 3y
0
now it's just assuming 'Really red' as an enum value whilst its being classed for brickcolourtext which is not using enum ISkyLordDoge 37 — 3y

1 answer

Log in to vote
0
Answered by
ImTrev 344 Moderation Voter
3 years ago
Edited 3 years ago
-- Server Script

local Replicated = game:GetService("ReplicatedStorage")

local allowed = {"ISkyLordDoge"}
local CanChange = Replicated.CanChange

game.Players.PlayerAdded:Connect(function(player)
    for i, v in pairs(allowed) do
        if player.Name == v then
            script.SendProperties:Clone().Parent = player:WaitForChild("PlayerGui")
        end
    end
end)

Replicated.ChangeProperties.OnServerEvent:Connect(function(player,BrickColorText,Material,Orientation,Position,Transparency)
    for i,v in pairs(allowed) do
        if player.Name == v then
            Replicated.ChangeProperties:FireAllClients(BrickColorText,Material,Orientation,Position,Transparency)
            CanChange.Value = false
            wait(5)
            CanChange.Value = true
        end
    end
end)



-- LocalScript

local Replicated = game:GetService("ReplicatedStorage")

local frame = script.Parent.Frame
local BrickColorText = frame.BrickColor
local Material = frame.Material
local Orientation = frame.Orientation
local Position = frame.PositionE
local Transparency = frame.TransparencyE

local part = worksapce.PropertyPart


script.Parent.Parent:WaitForChild("Toggle").MouseButton1Click:Connect(function()
    if script.Parent.Visible == true then
        script.Parent.Visible = false
    else
        script.Parent.Visible = true
    end
end)

local db = true
for i,property in pairs(frame:GetChildren()) do
    script.Parent.Submit.MouseButton1Click:Connect(function()
        if Replicated.CanChange.Value == true and db == true then
            db = false
            Replicated.ChangeProperties:FireServer(BrickColorText.Text,Material.Text,Orientation.Text,Position.Text,Transparency.Text)
        else
            db = false
            script.Parent.Submit.Text = "Cannot send now"
            wait(2)
            db = true
            script.Parent.Submit.Text = "Send"
        end
    end)    
end     

script.Parent.Cancel.MouseButton1Click:Connect(function()
    script.Parent.Visible = false   
end)
game.ReplicatedStorage.ChangeProperties.OnClientEvent:Connect(function(BrickColorText,Material,Orientation,Position,Transparency)
    part.BrickColor = BrickColor.new(tostring(BrickColorText))
    part.Material = Enum.Material[Material]
    part.Orientation = Vector3.new(Orientation)
    part.Position = Vector3.new(Position)
    part.Transparency = Transparency
end)


0
Oh my lord! Thank you so much! You don't know how much this will help when it comes to teaching my friends scripting! ISkyLordDoge 37 — 3y
0
Happy to help! ImTrev 344 — 3y
0
How would I make it affect the whole server instead of just my client? Is it possible? Thanks! ISkyLordDoge 37 — 3y
0
Delete lines 17 to 19 and replace it with lines 71 to 75 and then delete 70 down. ImTrev 344 — 3y
Ad

Answer this question