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

why cant script detect the same values?

this has really been pissing me off ive tried to get this stupid thing to work for an hour and i dont know why it wont. Ive tried like everything and nothing works.

if anyone knows why please tell me whats wrong with it

script.Parent.Touched:Connect(function(hit)
	local player = hit.Parent
	local playerp = game.Players:FindFirstChild(player.Name)
	if playerp then
		if playerp == script.Parent.Owner.Value then
			game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent:FireClient(player)
		else
			print"player does not own"
		end
	else
		print"no player found"
	end
end)
script.Parent.TouchEnded:Connect(function(hit)
	local player = hit.Parent
	local playerp = hit.Parent:FindFirstChild("Humanoid")
	if playerp then
		print(player)
		if player.Name   == script.Parent.Owner.Value then
			game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent.End:FireClient(player)
		else
			print"player does not own"
		end
	else
		print"no player found"
	end
	
end)


4 comments

0

dude your variable names are confusing change em u should young one and if my answer helped u on ur datastore question please accept it

0

Also did you mean to spell Workplace or Workspace after RemoteEvents?

0

You can also use :GetPlayerFromCharacter(). Also, you do have to tell us what it's printing, and set a print up on the client side for the event listener

0

i could accept the answer but the problem it didnt really change anything it still errors

3 answers

i decided to move it all local to the player instead of a remote event and it works just fine now.

For printing you gotta do

print("diwn aaodn ad ")

Use () on your strings..

1 comment

0

This is false. You can do print"test" and it'd work just fine. If you want to print anything else other than a string, you need parentheses

I think there is no issue with the script except the printing part. Here is the print syntax you must use print(int, object.. ext) or print("STRING") So your code should be written like that:

script.Parent.Touched:Connect(function(hit)
    local player = hit.Parent
	    local playerp = game.Players:FindFirstChild(player.Name)
	    if playerp then
	        if playerp == script.Parent.Owner.Value then
	            game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent:FireClient(player)
	        else
	            print("player does not own")
	        end
	    else
	        print("no player found")
	    end
	end)
	script.Parent.TouchEnded:Connect(function(hit)
	    local player = hit.Parent
	    local playerp = hit.Parent:FindFirstChild("Humanoid")
	    if playerp then
	        print(player)
	        if player.Name == script.Parent.Owner.Value then
	            game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent.End:FireClient(player)
	        else
	            print("player does not own")
	        end
	    else
	        print("no player found")
	    end
	end)

2 comments

0

Again, you can print without parentheses if it's a string

0

you dont need to use parentheses for printing strings

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