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

How do you make it so that on touch a part will change the time?

I have tried many times and have a script that just doesn't work

local part = script.Parent

part.Touched:Connect(function(hit)
print("Time part was touched by" .. hit.Name)
game.Lighting.ClockTime =14

What have I done wrong?

8 comments

0

I'm sure that's a IP grabber link. Therefore, I won't click it. ^

0

That is stupid bro, that is a website designed to tell why i downvoted this question

0

kk

0

Plus all sites you visit can see your IP anyways so why are you being so dramatic

0

IP Grabbers give people a certain persons IP, if they have a VPN on then they won't be able to see the true IP. If someone gets a real IP they can DDOS it and I don't like to trust dodgy-looking things.

0

go tell that to everyone at stackoverflow.com who uses idownvotedbecau.se to tell people why they downvoted a question LOL. I don't see them being DDoS'd. Plus if tons of people use a website that does that, why would they specifically do something to you, ok last off topic comment

0

Nice, I thought it was so you never had to call me 'stupid'. I don't use Stack Overflow so leave.

2 answers

This a basic syntax error I highly suggest you open the output for debugging. Also format your code correctly

local part = script.Parent

part.Touched:Connect(function(hit)
	print("Time part was touched by" .. hit.Name)
	game.Lighting.ClockTime = 14
end) -- You need to end the function

2 comments

0

You forgot a ) after end to close off the :Connect() call but this is better than the last answer

0

Count all the parenthesis again Connect accepts a callback argument so the closing parenthesis after end is the one you are talking about

local Players = game:GetService("Players")
local part

script.parent.Touched:Connect(function(part)
	
	local player = Players:GetPlayerFromCharacter(part.Parent)
	if not player then return end
	
	print("Time was changed by " .. player.Name)
	game.Lighting.ClockTime = math.random(23)
end)

Something like this.

1 comment

0

-1 for no explanation

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