What do you want to achieve? To make a custom dialogue system with GUI
What is the issue? Trying to make local scripts interact
What solutions have you tried so far? Part manipulation, number values, global variables
So I’m trying to make a dialogue system for my game. It’s been going so-so, as I was able to make it toggle able with it detecting a part’s transparency. However, local scripts can only detect transparency, and not manipulate it. Any ways to go around this problem?
I’m not really sure what you’re trying to achieve, but I think you might be looking for Bindable Event, that you can read more about here.
If you are trying to just make two local scripts on the same client communicate then changing the transparency should be sufficient. Updating a value in a local script will change that value for the client, meaning that you can see that change in other local scripts on that same client, but not on the server or local scripts running on other clients.
If you were using a bindable you might’ve been using it wrong, since you can only subscribe one connection per bindable. What that means is that you can fire the event from as many scripts as you’d like, but only connect one function to that event, for example like this:
local test1 = workspace:WaitForChild("test1"):WaitForChild("ClickDetector")
local dialogEnable = game.ReplicatedStorage:WaitForChild("DialogBindable")
test1.MouseClick:Connect(function()
dialogEnable:Fire("Test1")
end)
local test2 = workspace:WaitForChild("test2"):WaitForChild("ClickDetector")
local dialogEnable = game.ReplicatedStorage:WaitForChild("DialogBindable")
test2.MouseClick:Connect(function()
dialogEnable:Fire("Test2")
end)
dialogBindable.Event:Connect(function(sender)
if sender == "Test1" then
-- do dialog
elseif sender == "Test2" then
-- do other dialog
end
end)
In this demonstration I’m using clickdetectors inside parts to fire the event, but you can use whatever you’d like. The point is that you can only use the .Event one time but :Fire() as many times as you need. Also, if you for some reason still want to use change in transparency or some other property of a part then my suggestion is that you use the GetPropertyChangedSignal function, so that you can avoid using infinite loops that are going to slow down your game.