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

How can I get this RemoveEvent to recognise the client-side script's parent?

Asked by 7 years ago
Edited 7 years ago

Hello, I'm working my way slowly through converting my game in order to Enable Filtering.

I'm having a problem with a RemoteEvent, There is a list of Textboxes in PlayerGui that each have a client-side script in them. They communicate with a Server Side script which sets the TextStrokeTransparency of the selected TextBox's text to 0 when it's selected and is supposed to set it back to 1 when the 'Target' changes (Target is a string value set and removed based on what is selected) The problem I've found is when transferring data I cannot figure out how to get the server side script to recognise 'TextInput' (The selected texbox/parent of the client-side script) on the other end. Is there any way I could go about this that would allow 'TextInput' to be recognised as the correct TextBox in the Server Side script?

This is the Client-Side script

local event = game.ReplicatedStorage.SelectorEvent
local TextInput = script.Parent

script.Parent.MouseButton1Down:Connect(function()
    event:FireServer(TextInput)
end)

and this is the server side script that does not recognise 'TextInput'

local event = game.ReplicatedStorage.SelectorEvent
event.OnServerEvent:Connect(function(player, TextInput)
    local Target = game.ReplicatedStorage.Target
    print("Target")
    if TextInput.TextStrokeTransparency == 1 then
        print('Help?')
        TextInput.TextStrokeTransparency = 0
        Target.Value = TextInput

    elseif TextInput.TextStrokeTransparency == 0 then
        TextInput.TextStrokeTransparency = 1
        Target.Value = ""

    end

    Target.Changed:Connect(function()
        if Target.Value ~= TextInput then
            TextInput.TextStrokeTransparency = 1
        end
    end)

end)

as a sidenote, the Target.Changed function is also not doing anything. (The script works in solo mode but this one function refuses to set the TextStrokeTransparency back when 'Target' is changed) If anyone knows what I am doing wrong that would be helpful.

Many thanks!

1
Why are you using a remote event for this? This should not be handled by the server. ScriptGuider 5640 — 7y
0
Because the client broke as soon as filtering enabled was turned on Samstergizmo 28 — 7y
0
and How do I tell the difference between what I use a RemoveEvent for and what I don't? I tried using it on everything that broke because that seemed to make sense; unfortunately everyone is telling me to use one thing as Client-side only and another thing as a RemoveEvent, it's very confusing Samstergizmo 28 — 7y
0
I made a video on this a while ago that might clear things up for you: https://www.youtube.com/watch?v=4Dc_bri9mjs ScriptGuider 5640 — 7y

Answer this question