#Remote events are confusing

1 messages · Page 1 of 1 (latest)

gleaming hazel
#

I'm trying to send a remote event via a server script, and have a local script listen for it and change things accordingly so it's not tied to the server. But, when I touch the part and send the remote, the local script doesn't see it

Server Script =

local Players = game:GetService("Players")

script.Parent.Touched:Connect(function(hit)
    
    local character = hit.Parent
    local player = Players:GetPlayerFromCharacter(character)
    
    
    remote:FireClient(player)
    
end)

Local script =


remote.OnClientEvent:Connect(function()
    
    local border = workspace.Part.Border
    local gui = script.Parent.InteractGui

    if border:IsA("Model") then
        for _, part in pairs(border:GetDescendants()) do
            if part:IsA("BasePart") then
                part.Color = Color3.fromRGB(255, 255, 0)
            end
        end
    end

    gui.Idle.Visible = false
    gui.Interact.Visible = true
end)
shrewd wing
#

should your local script be workspace.InteractPart instead of workspace.Part?

gleaming hazel
narrow jacinthBOT
#

studio** You are now Level 2! **studio

shrewd wing
#

also you cant run regular LocalScripts in the workspace, they can only run inside your player or something owned by your client

#

unless its a regular script with the run context changed to client in properties

gleaming hazel
#

i just wanted to keep it organized, but idm throwing the local script in starter player scripts

shrewd wing
#

did it work if you put the local script in starter player scripts?

gleaming hazel
#

editing it so its actually going to the right places

#

Says "InteractPart is not a valid member of Model "game.workspace.Act.SideTextbox.Model"

local main = game.workspace.Act.SideTextbox.Model

local remote = main.InteractPart.Event

remote.OnClientEvent:Connect(function()
    
    print('gotten')
    
    local border = main.Border
    local gui = main.InteractPart.InteractGui

    if border:IsA("Model") then
        for _, part in pairs(border:GetDescendants()) do
            if part:IsA("BasePart") then
                part.Color = Color3.fromRGB(255, 255, 0)
            end
        end
    end

    gui.Idle.Visible = false
    gui.Interact.Visible = true
end)
shrewd wing
#

i assume its because your client hasnt loaded all the workspace in by the time the script runs

#

you can try using WaitForChild() on everything

gleaming hazel
#

Alright, that would make sense anyways

#

just feel like its messy if i use it all over

#

yup, that was it

#

Thank you again!!!!

shrewd wing
#

ok nice, you're welcome

atomic locust
shrewd wing
#

sorry lol