UIS Not Running When Player Touches a Part

I’m working on a Super Smash Bros type platform that lets the player jump up through the bottom and drop down from the top. It works fine save for one major detail.

The player gets onto the platform and the platform is supposed to ensure that the player is standing on it. It then waits for the player to press a key, where the platform will disable collisions and let the player fall through.

I looked for solutions around the devforum and couldn’t find any. I also asked some friends for their thoughts on the code and their solutions didn’t work either.

This is the code snippet that’s causing the problem:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid")then
		print("toucc")
		UIS.InputBegan:Connect(function(Input)
			print("began input")
			if  Input.KeyCode == Enum.KeyCode.LeftShift then
				print("drop")

It’s executing up to print(“toucc”) and then it doesn’t start detecting input. Is there a special way to do this? It looks to me like it should work fine, what’s going wrong? The output pane isn’t showing any errors, so I think this is a classic case of Manatee Wrote the Code Wrong™

Input only gets detected in a local script, it doesn’t detect player input if it’s in a script.

1 Like

To expand on this topic further, if you so need to get input from the server you can use a remote event to transfer that data.

1 Like

I put it in a localscript and it’s not detecting the player touching it either now. What’s even stranger is that I put it back into a normal script and it didn’t work either… I’ll keep you posted as I try to find this issue before I go back to fixing what I made the post for

I don’t think you can use the Touched function in a local script.

Actually I’m using Enum.Keycode, and it has to be the localplayer that presses the key. I’m really new to scripting so I dont even know how asking the server for a key press would even work (forgive me for making silly errors when I say new to scripting I mean really new)

So we have a function that only works on a localscript and another one that won’t work in a localscript? Well that’s a pickle, do you think there’s any way I can link the two scripts together somehow?

Just to hopefully understand the situation better, what are you making this for? Or are you just messing around with Lua.

Maybe you can do something like putting the touched function inside a server script and when it fires you can have a local script in Server Storage which you can clone to the player’s Gui.

My friend and I are making a Super Smash type game using custom Roblox avatars instead of Nintendo copyright property, because the two of us wanted to try to make a game that Roblox didn’t really have.

Do you think if I do that, I can make the platform only disable collisions for that one player? That’d be an added bonus, but it’s not a requirement

I wouldn’t use the touched function. The right thing to do is to use Collision Filtering.

Here’s an article: Collisions | Documentation - Roblox Creator Hub

Or you can make it so that the part is no can collide on the client.

I’ll look into using those options when it comes time to only toggle the part for individual players then, thanks!

For now I think I’ll stick to a more basic server-side CanCollide script, just so I can at least have a framework/working prototype to expand upon.

Thanks again for your suggestion though, it’s definately going to help me in the future!