Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why no one can fix my problem about touch event :C?

i have the same problem with this guy https://stackoverflow.com/questions/59436157/touched-function-roblox-studio please help me! ignore all wait,debounce,delay!

3 comments

0

Post your script?

0

i want to fix the problem of this guy! https://stackoverflow.com/questions/59436157/touched-function-roblox-studio i have the same problem as him fix his problem to fix mine!

0

Make the part you actuly touch taller, invisible, and not collide so the player stands inside it instead of on it. (Or even better: use rays)

2 answers

✓ Accepted answer

The way i solve this problem is to create a seperate non collideable box on top of the box you need the color changed.

and use .Touched and create a seperate function that checks if any player or anything still touching it with:GetTouchingPart()

vid : https://www.youtube.com/watch?v=TB-XrLsjfTo

debo = true
script.Parent.Touched:Connect(function()
	if debo then
		debo = false
		workspace.Part.BrickColor = BrickColor.Red()
		test = script.Parent:GetTouchingParts()
		checkTouch()
	end
end)


function checkTouch()
	while #test > 0 do
		wait()
		test = script.Parent:GetTouchingParts()
	end
	debo = true
	workspace.Part.BrickColor = BrickColor.Green()
end

This is just a rough idea on how to achieve this, you can try to modify this for better efficiency

Though i highly suggest not to use .Touched to achieve this and instead :

Try to use RayCasting instead, maybe find the part on ray from the client every time the player walk or a frame pass (RenderStep) and then change the color on the server (also create a way for it to not fire the server if the ray detect the same block over and over again), roblox's .Touched function is not very reliable on most cases

Edit : spelling and stuff

10 comments

0

subbed to your channel :>

0

THANK YOU SO MUCH!!!!!!!! your the one who solved my problem!

0

oopsie- did i was too late

0

ahhh i did too late so anyway lol

0

But wait, ImAnonymousBan, you said ' ignore all wait,debounce,delay!', but there some debouce tho, but anyways lol, I not kept saying anymore and, hope you good luck at your scripting travel!

0

lol im happy now because this problem kills me.

0

np happy to help, @Jack_Roblox2008 He probably meant the scrip ignore wait, debounce and delay and kept changing color despite having them

0

Also thanks for the sub, appreciate it :D

0

oo, im sorry for misturstanding you. but also good job XD, subbed.

0

yas, 200 points. i was a moderator voter now lol

Honestly, the script is working, but the script probably did wrong what they want to do.

First off, they kept shining, like a broken light bulb, that's not the thing that's he want to do, yeah, they accidentally do the wait(.5) inside the loop. So that's might be like that.

Yah, you can test it out this script:

local platform  = script.Parent

local function changeColor(part)
	part.BrickColor = BrickColor.new(‘Bright red’)
end

local function restoreColor(part)
	part.BrickColor = BrickColor.new(‘Grey’)
end

local function TouchedPlatform(plr)
	local h = plr.Parent:FindFirstChild("Humanoid") -- local the humanoid, and I literary bored and typed this lol
		wait(.5) -- wait, the another helps scripting website had telled, they want to wait 0.5 seconds that touched, and after 0.5 second of  touching the platform, they'll change the color. So, delete or no is your choice!
		changeColor() -- fires the changeColor function.
	if h then
		wait(.5) -- more information below of this
		changeColor() -- fires the changeColor function.
		else
		restoreColor()
	end
		
end

-- Information:
-- The other help scripting website had told, they want to wait 0.5 seconds that touched, and after 0.5 seconds of touching the platform, they'll change the color. So, delete or don't delete is your choice!

I didn't check this on the ROBLOX studio, and it might get a lot of messy, so ill not saying much more, good luck! I have more time tomorrow, if their problems, comment below and describe how was the bug is. I can't use the ROBLOX studio because this is my mobile phone, and sorry for you. But, thanks for reading this! I hope you have A NICE DAY! C:

tha edits: spellings, grammar, and type this xD

Also, if this worked, please upvote! :D

2 comments

0

not working lol ;-;

0

xd sorry lol i using the ipad so I cant test out roblox studio so uhm, lol.

This discussion is preserved as it was. New answers, comments, and votes are closed.